- Docs:
- Print whole JSDOM object -
screen.debug(result.container, Infinity);
- When to use
act
- https://github.com/threepointone/react-act-examples/blob/master/sync.md
- Print all entities in db -
console.log(testMirageServer.db.dump());
- Track requests for assertions
- testId -
data-testid
- kebab case -
long-test-id
- single test id as prop -
testId: 'id'
- multiple test id as prop -
testIds: { id1: 'id-1', id2: 'id-2' }
- headless
npm run cy:test -- --browser chrome
- Run tests in chrome browser in headless modenpm run cy:test -- --spec "cypress/specs/home.cy.ts"
- Run specific test file in headless mode
- headed
npm run cy:test:open
- Run tests in headed mode, closes on completionnpm run cy:test:open -- --spec "cypress/specs/home.cy.ts"
- Run specific test file in headed mode
- lauchpad
- first run
npm run cy:server:start
- Starts dev server with cypress env variables - then run
npm run cy:open
in a new terminal - Opens cypress launchpad (need to be closed manually).
- first run
- change
REACT_APP_MOCKER
in.cypress.env
to switch betweenmsw
andmirage
. Note: restart cypress after changing the value.
- headless
npm run pw:test
- Run tests in headless modenpm run pw:test specs/home.spec.ts
- Run specific test file in headless mode
- ui mode
npm run pw:test:open
- Stars dev server and then opens launchpad.
- Only msw as a mocker is supported in playwright.