Skip to content

Commit

Permalink
Use @swc/jest to speed up unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
richrace committed Sep 4, 2024
1 parent e6d3dbb commit cd132d3
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ dist
# Cypress artifacts
cypress/videos
cypress/screenshots

# SWC cache
.swc/
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,7 @@ public/images/govuk-mask-icon.svg
public/images/govuk-opengraph-image.png

# Ignore auto-generated zap.yaml
scripts/zap/zap.yaml
scripts/zap/zap.yaml

# SWC cache
.swc/
17 changes: 17 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"target": "esnext"
},
"module": {
"type": "commonjs"
}
}
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */

module.exports = {
preset: "ts-jest",
setupFilesAfterEnv: ["<rootDir>/setupTests.ts"],
Expand All @@ -11,5 +12,8 @@ module.exports = {
"^entities/(.*)$": "<rootDir>/src/entities/$1",
"^services/(.*)$": "<rootDir>/src/services/$1",
"^middleware/(.*)$": "<rootDir>/src/middleware/$1"
},
transform: {
"^.+\\.(t|j)sx?$": "@swc/jest"
}
}
244 changes: 244 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"zap": "./scripts/zap/zap-scan.sh"
},
"dependencies": {
"@govuk-react/table": "^0.10.7",
"@govuk-react/select": "^0.10.7",
"@govuk-react/table": "^0.10.7",
"@ministryofjustice/frontend": "^2.2.0",
"@moj-bichard7-developers/bichard7-next-core": "^2.0.9",
"@moj-bichard7-developers/bichard7-next-data": "^2.0.205",
Expand Down Expand Up @@ -76,6 +76,8 @@
"@next/eslint-plugin-next": "^14.2.7",
"@stdlib/random-base-exponential": "^0.2.1",
"@stdlib/random-sample": "^0.2.1",
"@swc/core": "^1.7.23",
"@swc/jest": "^0.2.36",
"@testing-library/cypress": "^10.0.2",
"@testing-library/jest-dom": "^6.5.0",
"@types/cookie-signature": "^1.1.2",
Expand Down

0 comments on commit cd132d3

Please sign in to comment.