-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(unit): setup jest, add tests + gh workflow
test(unit): add tests for components test(unit): fix Intoto001 test test(unit): fix Explorer test test(unit): fix Settings test test(unit): fix SearchForm fix issue with userEvent fix issue with nested anchor links test(unit): add test for decode increase coverage for decode ci(test): add workflow to run unit tests for pull requests fix: allow isolatedModules for tests to support typed mocks remove ts disabling for tests Signed-off-by: kahboom <[email protected]>
- Loading branch information
Showing
27 changed files
with
17,175 additions
and
5,930 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: 🧪 Unit Tests (Jest) | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
build: | ||
name: 🧪 Unit Tests (Jest) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: 📦 Install modules | ||
run: npm install | ||
- name: ⚙️ Run tests | ||
run: npm run test --coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const nextJest = require("next/jest"); | ||
|
||
const createJestConfig = nextJest({ | ||
dir: "./", | ||
}); | ||
|
||
/** @type {import('jest').Config} */ | ||
const config = { | ||
// automatically clear mock calls and instances between every test | ||
clearMocks: true, | ||
|
||
// whether the coverage information should be collected while executing the test | ||
collectCoverage: true, | ||
|
||
// directory where Jest should output its coverage files | ||
coverageDirectory: "coverage", | ||
coverageProvider: "v8", | ||
|
||
globals: { | ||
"ts-jest": { | ||
tsconfig: "<rootDir>/tsconfig.test.json", | ||
}, | ||
}, | ||
|
||
moduleNameMapper: { | ||
// handle module aliases | ||
"^@/components/(.*)$": "<rootDir>/components/$1", | ||
}, | ||
|
||
// add more setup options before each test is run | ||
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"], | ||
|
||
testEnvironment: "jest-environment-jsdom", | ||
|
||
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/.next/"], | ||
|
||
transformIgnorePatterns: [ | ||
"/node_modules/", | ||
"^.+\\.module\\.(css|sass|scss)$", | ||
], | ||
verbose: true, | ||
}; | ||
|
||
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async | ||
module.exports = createJestConfig(config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// learn more: https://github.com/testing-library/jest-dom | ||
import "@testing-library/jest-dom"; | ||
import { TextEncoder, TextDecoder } from "util"; | ||
|
||
Object.assign(global, { TextDecoder, TextEncoder }); |
Oops, something went wrong.