You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- How is this different from [Enzyme](https://github.com/airbnb/enzyme) or [RTL](https://testing-library.com/docs/react-testing-library/intro)? It is similar in functionality BUT runs the component in the real browser with full power of Cypress E2E test runner: [live GUI, full API, screen recording, CI support, cross-platform](https://www.cypress.io/features/), and [visual testing](https://on.cypress.io/visual-testing). Ohh, and the code coverage is built-in!
11
+
- How is this different from [Enzyme](https://github.com/airbnb/enzyme) or [RTL](https://testing-library.com/docs/react-testing-library/intro)? It is similar in functionality BUT runs the component in the real browser with full power of Cypress E2E test runner: [live GUI, full API, screen recording, CI support, cross-platform](https://www.cypress.io/features/), and [visual testing](https://on.cypress.io/visual-testing).
12
12
- If you like using `@testing-library/react`, you can use `@testing-library/cypress` for the same `findBy`, `queryBy` commands, see one of the examples in the list below
13
-
- Read [My Vision for Component Tests in Cypress](https://glebbahmutov.com/blog/my-vision-for-component-tests/)
13
+
- Read [My Vision for Component Tests in Cypress](https://glebbahmutov.com/blog/my-vision-for-component-tests/) by Gleb Bahmutov
14
14
15
15
## Comparison
16
16
@@ -54,10 +54,10 @@ If you are coming from Enzyme world, check out the [enzyme](cypress/component/ba
54
54
55
55
## Install
56
56
57
-
Requires [Node](https://nodejs.org/en/) version 8 or above.
57
+
Requires [Node](https://nodejs.org/en/) version 12 or above.
@@ -371,44 +371,13 @@ Finally, when running tests on the continuous integration service, the true test
371
371
372
372
</details>
373
373
374
-
<detailsid="speed">
375
-
<summary>Slow bundling</summary>
376
-
377
-
When you bundle spec file, you are now bundling React, Read DOM and other libraries, which is might be slow. For now, you can disable inline source maps by adding to your Webpack config settings (if available) the following:
378
-
379
-
```js
380
-
constwebpackOptions= {
381
-
devtool:false,
382
-
}
383
-
```
384
-
385
-
Keep your eye on issue [#9663](https://github.com/cypress-io/cypress/issues/9663) for more information.
386
-
387
-
</details>
388
-
389
-
<detailsid="missing-code-coverage">
390
-
<summary>Missing code coverage</summary>
391
-
392
-
If you are using your custom Webpack, this plugin might be missing code coverage information because the code was not instrumented. We try to insert the `babel-plugin-istanbul` plugin automatically, but your bundling might not use Babel, or configure it differently, preventing plugin insertion. Please let us know by opening an issue with full reproducible details.
393
-
394
-
See related issue [#141](https://github.com/bahmutov/cypress-react-unit-test/react/issues/141). You can also debug the plugin's behavior by running it with `DEBUG` environment variable, see [#debugging](#debugging) section.
395
-
396
-
</details>
397
-
398
-
<detailsid="gatsby-not-supported">
399
-
<summary>Gatsby.js projects not supported</summary>
400
-
401
-
Currently, this project cannot find Webpack settings used by Gatsby.js, thus it cannot bundle specs and application code correctly. Keep an eye on [#307](https://github.com/cypress-io/cypress/issues/9671)
402
-
403
-
</details>
404
-
405
374
## Context Provider usage
406
375
407
376
React context provider usage and API described in [./docs/providers-and-composition.md](./docs/providers-and-composition.md)
408
377
409
378
## Chat
410
379
411
-
We have a chat workspace at [https://component-testing.slack.com/](https://component-testing.slack.com/), you are welcome to [join us](https://join.slack.com/t/component-testing/shared_invite/zt-h93lrgsl-8WzE8yNQlcZuZji_gA_mtg).
380
+
Come chat with us [on discord](https://discord.gg/7ZHYhZSW) in the #component-testing channel.
> **Note** this package is not meant to be used outside of cypress component testing.
22
+
23
+
Install `@cypress/vue` or `@cypress/react` to get this package working properly
24
+
25
+
## Architecture
26
+
27
+
### Cypress server
28
+
29
+
- Every HTTP request goes to the cypress server which returns an html page. We call "TOP" because of its name in the dev tools
30
+
This page
31
+
- renders the list of spec files
32
+
- And the timetraveling command log
33
+
- Finally, it renders an AUT Iframe. this iframe calls a url that has 2 parts concatenated.
34
+
- a prefix: `__cypress/iframes/`
35
+
- the path to the current. For example: `src/components/button.spec.tsx`
36
+
- In the cypress server, calls prefixed with `__cypress/iframes/...` will be passed to the dev-server as `__cypress/src/index.html`
37
+
- Every call with the prefix `__cypress/src/` will be passed to the dev-server to deal as is, without changes.
38
+
39
+
### Dev-server
40
+
41
+
- Responds to every query with the prefix `__cypress/src/` (base path should be this prefix).
42
+
- Responds to `__cypress/src/index.html` with an html page.
43
+
This page
44
+
- will contain an element `<div id="__cy_root"></div>`. Tis will be used by mount function to mount the app containing the components we want.
45
+
- will load support files
46
+
- will load the current spec from the url
47
+
- will start the test when both files are done loading
48
+
- The server re-runs the tests as soon as the current spec or any dependency is updated by calling an event `devServerEvents.emit('dev-server:compile:success')`
49
+
50
+
## Vite dev server
51
+
52
+
- Takes the users `vite.config` and adds base of `__cypress/src/` and a cypress vite plugin.
53
+
- The cypress plugin takes care of
54
+
- responding to the index.html query with an html page
55
+
- restarting the tests when files are changed
56
+
- The HTML page calls a script that loads support file and the specs using a native `import()` function
57
+
- Then triggers the loaded tests
58
+
59
+
Vite is reponsible for compiling and bundling all the files. We use its error overlay to display any transpiling error.
60
+
Omly runtime errors have to be handled through cypress
0 commit comments