Make sure to get familiar with the cypress component docs.
- Do not create e2e tests, these tests are supposed to be only used for visual component testing.
- If you need to mock some API calls, use the cy.intercept stub.
- Do not store videos of tests
- Only create test files inside the
cypress/component
directory. - Test files must end with
cy.ts
orcy.tsx
extensions. - To get the browser snapshots, we have to query for the
html
tag!
run npm i
const elem = cy.mount(<Banner />).get('html')
elem.matchImageSnapshot()
The .get('html')
is a critical part. The snapshot only accepts DOM.
npm run test:ct
npm run test:ct -- -u
To run the tests in interactive env use
npx cypress open
Visual snapshots are not accurate when setting the viewport size manually!
If a snapshot is mismatched, the interactive mode will not show/store the diff!