Skip to content

Commit bcd3f28

Browse files
authored
test: add basic unit tests (#27)
* test: add basic unit tests Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com> * add test reults in ci Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com> * test default config Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com> --------- Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
1 parent c7bdc49 commit bcd3f28

9 files changed

Lines changed: 7290 additions & 3216 deletions

File tree

.github/workflows/pr-check.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,33 @@ jobs:
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v4
19+
1920
- name: Setup Node
2021
uses: actions/setup-node@v4
2122
with:
2223
node-version-file: '.nvmrc'
2324
cache: 'npm'
25+
2426
- name: Restore cache
2527
uses: actions/cache@v4
2628
with:
2729
path: .next/cache
2830
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
2931
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
32+
3033
- name: Install dependencies
3134
run: npm ci
35+
36+
- name: Run test
37+
run: npm test
38+
39+
- name: Publish Test Report
40+
if: always()
41+
uses: ctrf-io/github-test-reporter@v1
42+
with:
43+
report-path: './ctrf/*.json'
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
3247
- name: Build with Next.js
3348
run: npm run build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# testing
1010
/coverage
11+
/ctrf
1112

1213
# next.js
1314
/.next/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const useAutoAnimate = () => [null];
2+
export { useAutoAnimate };

jest.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// eslint-disable-next-line @typescript-eslint/no-require-imports
2+
const nextJest = require("next/jest");
3+
4+
const createJestConfig = nextJest({
5+
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
6+
dir: "./",
7+
});
8+
9+
// Add any custom config to be passed to Jest
10+
/** @type {import('jest').Config} */
11+
const customJestConfig = {
12+
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
13+
testEnvironment: "jsdom",
14+
reporters: ["default", ["jest-ctrf-json-reporter", {}]],
15+
};
16+
17+
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
18+
module.exports = createJestConfig(customJestConfig);

jest.setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Learn more: https://github.com/testing-library/jest-dom
2+
import "@testing-library/jest-dom";

0 commit comments

Comments
 (0)