Skip to content

Commit 7314d66

Browse files
authored
Merge pull request #15746 from cypress-io/fix/audit-and-update-readmes
docs: update Readme.md
2 parents 8ed9e99 + 5028baf commit 7314d66

File tree

6 files changed

+166
-196
lines changed

6 files changed

+166
-196
lines changed

npm/react/README.md

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
> A little helper to unit test React components in the open source [Cypress.io](https://www.cypress.io/) E2E test runner **v4.5.0+**
1+
> A little helper to unit test React components in the open source [Cypress.io](https://www.cypress.io/) test runner **v7.0.0+**
22
33
**Jump to:** [Comparison](#comparison), [Blog posts](#blog-posts), [Install](#install), Examples: [basic](#basic-examples), [advanced](#advanced-examples), [full](#full-examples), [external](#external-examples), [Style options](#options), [Code coverage](#code-coverage), [Visual testing](#visual-testing), [Common problems](#common-problems), [Chat](#chat)
44

@@ -8,9 +8,9 @@
88

99
![Example component test](images/dynamic.gif)
1010

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). 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).
1212
- 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
1414

1515
## Comparison
1616

@@ -54,10 +54,10 @@ If you are coming from Enzyme world, check out the [enzyme](cypress/component/ba
5454

5555
## Install
5656

57-
Requires [Node](https://nodejs.org/en/) version 8 or above.
57+
Requires [Node](https://nodejs.org/en/) version 12 or above.
5858

5959
```sh
60-
npm install --save-dev cypress @cypress/react
60+
npm install --save-dev cypress @cypress/react @cypress/webpack-dev-server
6161
```
6262

6363
## Init
@@ -371,44 +371,13 @@ Finally, when running tests on the continuous integration service, the true test
371371

372372
</details>
373373

374-
<details id="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-
const webpackOptions = {
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-
<details id="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-
<details id="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-
405374
## Context Provider usage
406375

407376
React context provider usage and API described in [./docs/providers-and-composition.md](./docs/providers-and-composition.md)
408377

409378
## Chat
410379

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.
412381

413382
## Development
414383

@@ -432,12 +401,9 @@ DEBUG=@cypress/react,find-webpack
432401

433402
Same feature for unit testing components from other frameworks using Cypress
434403

435-
- [cypress-vue-unit-test](https://github.com/bahmutov/cypress-vue-unit-test)
404+
- [@cypress/vue](https://github.com/cypress-io/cypress/tree/develop/npm/vue)
436405
- [cypress-cycle-unit-test](https://github.com/bahmutov/cypress-cycle-unit-test)
437406
- [cypress-svelte-unit-test](https://github.com/bahmutov/cypress-svelte-unit-test)
438407
- [cypress-angular-unit-test](https://github.com/bahmutov/cypress-angular-unit-test)
439408
- [cypress-hyperapp-unit-test](https://github.com/bahmutov/cypress-hyperapp-unit-test)
440409
- [cypress-angularjs-unit-test](https://github.com/bahmutov/cypress-angularjs-unit-test)
441-
442-
[renovate-badge]: https://img.shields.io/badge/renovate-app-blue.svg
443-
[renovate-app]: https://renovateapp.com/

npm/react/images/dynamic.gif

2.42 MB
Loading

npm/vite-dev-server/README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# ⚡️ + 🌲 Cypress Component Testing w/ Vite
1+
# @cypress/vite-dev-server
2+
3+
> ⚡️ + 🌲 Cypress Component Testing w/ Vite
24
35
To install vite in you component testing environment,
46
1. Install it `yarn add @cypress/vite-dev-server`
@@ -13,3 +15,46 @@ module.exports = (on, config) => {
1315
return config
1416
}
1517
```
18+
19+
# @cypress/webpack-dev-server
20+
21+
> **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

Comments
 (0)