Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit ed33d6a

Browse files
committed
add links to more projects and full cypress json file
1 parent e9773d9 commit ed33d6a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ describe('HelloState component', () => {
5151
// mounted component can be selected via its name, function, or JSX
5252
// e.g. '@HelloState', HelloState, or <HelloState />
5353
cy.get(HelloState).invoke('setState', { name: 'React' })
54-
cy.get(HelloState)
55-
.its('state')
56-
.should('deep.equal', { name: 'React' })
54+
cy.get(HelloState).its('state').should('deep.equal', { name: 'React' })
5755
// check if GUI has rerendered
5856
cy.contains('Hello React!')
5957
})
@@ -100,7 +98,7 @@ import './styles.css'
10098
You can read the CSS file and pass it as `style` option yourself
10199

102100
```js
103-
cy.readFile('cypress/integration/Button.css').then(style => {
101+
cy.readFile('cypress/integration/Button.css').then((style) => {
104102
cy.mount(<Button name="Orange" orange />, { style })
105103
})
106104
```
@@ -156,14 +154,25 @@ If you are using Create-React-App v3 or `react-scripts`, and want to reuse the b
156154
}
157155
```
158156

159-
See example repo [bahmutov/try-cra-with-unit-test](https://github.com/bahmutov/try-cra-with-unit-test)
157+
See example repo [bahmutov/try-cra-with-unit-test](https://github.com/bahmutov/try-cra-with-unit-test), typical full config with specs and source files in `src` folder (before [ejecting the app](https://github.com/bahmutov/cypress-react-unit-test/issues/134)):
158+
159+
```json
160+
{
161+
"fixturesFolder": false,
162+
"pluginsFile": "node_modules/cypress-react-unit-test/plugins/cra-v3",
163+
"supportFile": "node_modules/cypress-react-unit-test/support",
164+
"testFiles": "**/*.spec.js",
165+
"experimentalComponentTesting": true,
166+
"componentFolder": "src"
167+
}
168+
```
160169

161170
If you already have a plugins file, you can use a file preprocessor that points at CRA's webpack
162171

163172
```js
164173
// your project's Cypress plugin file
165174
const craFilePreprocessor = require('cypress-react-unit-test/plugins/cra-v3/file-preprocessor')
166-
module.exports = on => {
175+
module.exports = (on) => {
167176
on('file:preprocessor', craFilePreprocessor())
168177
}
169178
```
@@ -186,6 +195,8 @@ All components are in [src](src) folder. All tests are in [cypress/integration](
186195
## Large examples
187196

188197
- [bahmutov/calculator](https://github.com/bahmutov/calculator) tests multiple components: calculator App, Button, Display.
198+
- [bahmutov/react-todo-with-hooks](https://github.com/bahmutov/react-todo-with-hooks) branch `added-tests`
199+
- [bahmutov/test-redux-examples](https://github.com/bahmutov/test-redux-examples) branch `mount2`
189200

190201
## Development
191202

0 commit comments

Comments
 (0)