|
| 1 | +# Component Testing Example: Create Next App + Webpack 4 |
| 2 | + |
| 3 | +This is an example **Create Next App + Webpack 4** project with Cypress component testing. |
| 4 | + |
| 5 | +- `yarn` to install the dependencies |
| 6 | +- `npx cypress open-ct` to run interactively |
| 7 | +- `npx cypress run-ct` to run all tests headlessly |
| 8 | + |
| 9 | +The following was done to create this example: |
| 10 | + |
| 11 | +1. Initialize a baseline "nested-components" project in the [setup-create-next-app-webpack-4](.) subdirectory |
| 12 | + 1. `yarn create next-app --example nested-components setup-create-next-app-webpack-4` |
| 13 | + 2. `cd setup-create-next-app-webpack-4` |
| 14 | + 3. Commit [`f292831`](https://github.com/cypress-io/cypress-component-testing-examples/commit/f292831e0c4c5d84d458f20098ca3e4d5eb7cf0c) |
| 15 | +2. Add Cypress component testing support with sample tests |
| 16 | + 1. `yarn add next@10` |
| 17 | + 2. Add [cypress.json](cypress.json) |
| 18 | + 3. Add [cypress/plugins/index.js](cypress/plugins/index.js) |
| 19 | + 4. Add [components/paragraph.spec.ct.js](components/paragraph.spec.ct.js), [components/post.spec.ct.js](components/post.spec.ct.js), [pages/index.spec.ct.js](pages/index.spec.ct.js) |
| 20 | + 5. `npx cypress open-ct` |
| 21 | + 6. Commit [`d09f7c5`](https://github.com/cypress-io/cypress-component-testing-examples/commit/d09f7c5762c256514f1eb6a178b4e9f96f536fd5) |
| 22 | +3. Add Cypress Code Coverage |
| 23 | + 1. `yarn add -D https://cdn.cypress.io/beta/npm/10.0.0/linux-x64/10.0-release-188b9a742ee2ef51102167bfd84b3696a3f72a26/cypress.tgz webpack@4 webpack-dev-server @cypress/react @cypress/webpack-dev-server html-webpack-plugin@4` |
| 24 | + 2. Edit [cypress.config.js](cypress.config.js) to enable `coverage` and configure the Cypress code coverage task |
| 25 | + 3. Edit [.gitignore](.gitignore) to ignore .nyc_output directory |
| 26 | + 4. Edit [cypress/support/component.js](cypress/support/component.js) to import Cypress code coverage support |
| 27 | + 5. Add [.babelrc](.babelrc) to `babel-plugin-istanbul` when Cypress Component tests are running |
| 28 | + 6. Commit [`4d76aa2`](https://github.com/cypress-io/cypress-component-testing-examples/commit/4d76aa2e27a061b91d19c947ea31d3beef95391a) |
| 29 | + |
| 30 | +_This example was generated by [setup-create-next-app-webpack-4.sh](https://github.com/cypress-io/cypress-component-testing-examples/blob/main/scripts/setup-create-next-app-webpack-4.sh) on 2022-03-23. The original README follows._ |
| 31 | + |
| 32 | +--- |
| 33 | + |
1 | 34 | # Example app using nested components
|
2 | 35 |
|
3 | 36 | Taking advantage of the composable nature of React components we can modularize our apps in self-contained, meaningful components. This example has a page under `pages/index.js` that uses `components/paragraph.js` and `components/post.js` that can be styled and managed separately.
|
|
0 commit comments