Skip to content

Commit

Permalink
tests(#57): fix Jest configuration and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
damien-carcel committed Nov 12, 2023
1 parent 7572d93 commit ea12bcb
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 159 deletions.
14 changes: 7 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,30 @@ jobs:
- ./.next/cache
- run:
name: Check the code style
command: task tests:check-code-style
command: task tests:static:prettier:check
- run:
name: Lint the stylesheets
command: task tests:lint-css
command: task tests:static:css:lint
- run:
name: Lint the application code
command: task tests:lint-ts -- --format junit -o test_results/eslint.xml
command: task tests:static:ts:lint -- --format junit -o test_results/eslint.xml
- run:
name: Check the code typing
command: task tests:check-types
command: task tests:static:types:check
- run:
name: Run unit tests
environment:
JEST_JUNIT_OUTPUT_DIR: test_results
JEST_JUNIT_OUTPUT_NAME: unit.xml
command: task tests:unit-tests -- --reporters=default --reporters=jest-junit
command: task tests:unit:run -- --reporters=default --reporters=jest-junit
- run:
name: Run component tests
command: task tests:component-tests-headless
command: task tests:component:headless
- run:
name: Run end-to-end tests
command: |
task run:database
task run:migrate
task tests:e2e-tests-headless
task tests:e2e:headless
- store_test_results:
path: test_results
197 changes: 101 additions & 96 deletions __tests__/__snapshots__/snapshot.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,120 +2,125 @@

exports[`renders homepage unchanged 1`] = `
<div>
<div
class="container"
<main
class="main"
>
<main
class="main"
<div
class="description"
>
<h1
class="title"
>
Welcome to
<a
href="https://nextjs.org"
>
Next.js!
</a>
</h1>
<p
class="description"
>
Get started by editing
<p>
Get started by editing 
<code
class="code"
>
pages/index.js
src/app/page.tsx
</code>
</p>
<div
class="grid"
>
<div>
<a
class="card"
href="/about"
>
<h2>
About Page →
</h2>
<p>
Cypress will test if this link is working.
</p>
</a>
<a
class="card"
href="https://nextjs.org/docs"
>
<h2>
Documentation →
</h2>
<p>
Find in-depth information about Next.js features and API.
</p>
</a>
<a
class="card"
href="https://nextjs.org/learn"
>
<h2>
Learn →
</h2>
<p>
Learn about Next.js in an interactive course with quizzes!
</p>
</a>
<a
class="card"
href="https://github.com/vercel/next.js/tree/canary/examples"
>
<h2>
Examples →
</h2>
<p>
Discover and deploy boilerplate example Next.js projects.
</p>
</a>
<a
class="card"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
rel="noopener noreferrer"
target="_blank"
>
<h2>
Deploy →
</h2>
<p>
Instantly deploy your Next.js site to a public URL with Vercel.
</p>
</a>
</div>
</main>
<footer
class="footer"
>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
rel="noopener noreferrer"
target="_blank"
>
Powered by
<span
class="logo"
>
By
<img
alt="Vercel Logo"
class="vercelLogo"
data-nimg="1"
decoding="async"
height="16"
loading="lazy"
fetchpriority="high"
height="24"
src="/vercel.svg"
style="color: transparent;"
width="72"
width="100"
/>
</span>
</a>
</div>
</div>
<div
class="center"
>
<img
alt="Next.js Logo"
class="logo"
data-nimg="1"
decoding="async"
fetchpriority="high"
height="37"
src="/next.svg"
style="color: transparent;"
width="180"
/>
</div>
<div
class="grid"
>
<a
class="card"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
rel="noopener noreferrer"
target="_blank"
>
<h2>
Docs
<span>
-&gt;
</span>
</h2>
<p>
Find in-depth information about Next.js features and API.
</p>
</a>
<a
class="card"
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
rel="noopener noreferrer"
target="_blank"
>
<h2>
Learn
<span>
-&gt;
</span>
</h2>
<p>
Learn about Next.js in an interactive course with quizzes!
</p>
</a>
<a
class="card"
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
rel="noopener noreferrer"
target="_blank"
>
<h2>
Templates
<span>
-&gt;
</span>
</h2>
<p>
Explore starter templates for Next.js.
</p>
</a>
<a
class="card"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
rel="noopener noreferrer"
target="_blank"
>
<h2>
Deploy
<span>
-&gt;
</span>
</h2>
<p>
Instantly deploy your Next.js site to a shareable URL with Vercel.
</p>
</a>
</footer>
</div>
</div>
</main>
</div>
`;
3 changes: 2 additions & 1 deletion __tests__/snapshot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render } from '@testing-library/react';
import Home from '../pages/index';

import Home from '@/app/page';

it('renders homepage unchanged', () => {
const { container } = render(<Home />);
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
"build": "next build",
"start": "next start",
"migrate": "node-pg-migrate",
"e2e": "start-server-and-test dev http://localhost:3000 \"cypress open --e2e\"",
"e2e:headless": "start-server-and-test dev http://localhost:3000 \"cypress run --e2e --record\"",
"component": "cypress open --component",
"component:headless": "cypress run --component --record",
"unit:watch": "jest --watch",
"unit:ci": "jest --ci",
"lint:js": "next lint",
"lint:css": "stylelint '**/*.css'",
"prettier": "prettier '**/*.{ts,tsx}'",
"typecheck": "tsc -b"
"tests:component": "cypress open --component",
"tests:component:headless": "cypress run --component --record",
"tests:e2e": "start-server-and-test dev http://localhost:3000 \"cypress open --e2e\"",
"tests:e2e:headless": "start-server-and-test dev http://localhost:3000 \"cypress run --e2e --record\"",
"tests:lint:css": "stylelint '**/*.css'",
"tests:lint:js": "next lint",
"tests:prettier": "prettier '**/*.{ts,tsx}'",
"tests:typecheck": "tsc -b",
"tests:unit:ci": "jest --ci",
"tests:unit:update-snapshots": "jest --jest --updateSnapshot",
"tests:unit:watch": "jest --watch"
},
"engines": {
"node": ">=18.0.0 <19.0.0"
Expand Down
Loading

0 comments on commit ea12bcb

Please sign in to comment.