mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-03 21:40:28 -05:00
5e4b638385
Co-authored-by: Jessica Sachs <jess@jessicasachs.io>
46 lines
942 B
Markdown
46 lines
942 B
Markdown
# example: webpack-options
|
|
|
|
> The Webpack preprocessor in [cypress/plugins/index.js](cypress/plugins/index.js) adds the Babel React preset to the list of default Webpack plugins. This allows Cypress to transpile JSX code in [cypress/component/Test.cy-spec.js](cypress/component/Test.cy-spec.js) file.
|
|
|
|
## Usage
|
|
|
|
1. Make sure the root project has been built .
|
|
|
|
```bash
|
|
# in the root of the project
|
|
npm install
|
|
npm run build
|
|
```
|
|
|
|
2. Run `npm install` in this folder to symlink the `@cypress/react` dependency.
|
|
|
|
```bash
|
|
# in this folder
|
|
npm install
|
|
```
|
|
|
|
3. Start Cypress
|
|
|
|
```bash
|
|
npm run cy:open
|
|
# or just run headless tests
|
|
npm test
|
|
```
|
|
|
|
## Example
|
|
|
|
```js
|
|
import React from 'react'
|
|
import { mount } from '@cypress/react'
|
|
describe('components', () => {
|
|
it('works', () => {
|
|
mount(<div>Text</div>)
|
|
cy.contains('Text')
|
|
})
|
|
})
|
|
```
|
|
|
|

|
|
|
|
More tests are in the [cypress/component](cypress/component) folder.
|