Closed halsk closed 2 years ago
This is the official nextjs page for testing https://nextjs.org/docs/testing
@MaySoMusician
E2E test worked but the unit test didn't work. Here is the log.
% yarn test:ci
yarn run v1.22.17
$ jest --ci
"next/jest" is currently experimental. https://nextjs.org/docs/messages/experimental-jest-transformer
FAIL cypress/integration/app.spec.js
● example test › shows the top page
ReferenceError: cy is not defined
3 | describe('example test', () => {
4 | it('shows the top page', () => {
> 5 | cy.visit('http://localhost:3000/');
| ^
6 | cy.get('h1').contains('Find wonderful projects');
7 | });
8 | });
at Object.<anonymous> (cypress/integration/app.spec.js:5:9)
PASS __test__/atoms/button/PrimaryButton.test.tsx
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 failed, 1 passed, 2 total
Snapshots: 0 total
Time: 1.56 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@halsk It seems that Jest wrongly runs the E2E tests. yarn test:ci
should not touch the tests in cypress/
. I'll do deeper investigation.
I've found the way to tell Jest to ignore Cypress tests.
Goal:
As a developer, I want to develop with a test-driven process so that I can keep code quality high.
Tasks:
Acceptance Criteria: