The Webpack preprocessor in 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 file.
Note: run npm install
in this folder to symlink cypress-react-unit-test
dependency.
npm run cy:open
# or run headless tests
npm test
import React from 'react'
import { mount } from 'cypress-react-unit-test'
describe('components', () => {
it('works', () => {
mount(<div>Text</div>)
cy.contains('Text')
})
})
More tests are in the cypress/component folder.