Skip to content

Commit

Permalink
Speed up jest with changes from template project (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpmcgowan authored Jan 5, 2023
1 parent 62c1560 commit c134d80
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: unit tests
command: npm run test
command: npm run test:ci
- store_test_results:
path: test_results
- store_artifacts:
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

NODE_ENV=dev && node_modules/.bin/lint-staged && node_modules/.bin/tsc && npm test
NODE_ENV=dev && node_modules/.bin/lint-staged && npm run typecheck && npm test
54 changes: 0 additions & 54 deletions package-lock.json

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

16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"record-build-info": "node ./bin/record-build-info",
"lint": "eslint . --cache --max-warnings 0",
"typecheck": "tsc && tsc -p integration_tests",
"test": "jest --runInBand --detectOpenHandles",
"test": "jest --coverage",
"test:ci": "jest --runInBand --coverage",
"security_audit": "npx audit-ci --config audit-ci.json",
"int-test": "cypress run --config video=false --env $(grep ONE_TIME_CODE_AUTH_ENABLED feature.env)",
"int-test-ui": "cypress open --env $(grep ONE_TIME_CODE_AUTH_ENABLED feature.env)",
Expand All @@ -33,7 +34,14 @@
},
"jest": {
"preset": "ts-jest",
"collectCoverage": true,
"transform": {
"^.+\\.tsx?$": [
"ts-jest",
{
"isolatedModules": true
}
]
},
"collectCoverageFrom": [
"server/**/*.{ts,js,jsx,mjs}"
],
Expand Down Expand Up @@ -63,8 +71,7 @@
"json",
"node",
"ts"
],
"testRunner": "jest-jasmine2"
]
},
"nodemonConfig": {
"ignore": [
Expand Down Expand Up @@ -166,7 +173,6 @@
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"jest-html-reporter": "^3.7.0",
"jest-jasmine2": "^29.2.1",
"jest-junit": "^14.0.1",
"lint-staged": "^13.0.3",
"mocha-junit-reporter": "^2.2.0",
Expand Down
1 change: 1 addition & 0 deletions server/data/healthCheck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('Service healthcheck', () => {
})

afterEach(() => {
nock.abortPendingRequests()
nock.cleanAll()
})

Expand Down
7 changes: 3 additions & 4 deletions server/services/cjsm/CjsmService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('CjsmService', () => {
expect(userDetails).toStrictEqual(expectedResponse)
})

it('should return not found', async done => {
it('should return not found', () => {
const expectedError = {
status: 404,
errorCode: {
Expand All @@ -40,9 +40,8 @@ describe('CjsmService', () => {
}
mockedSendLegalMailApi.get('/cjsm/user/me').reply(404, expectedError)

cjsmService.getUserDetails('some-token').catch(error => {
expect(JSON.parse(error.text)).toStrictEqual(expectedError)
done()
return cjsmService.getUserDetails('some-token').catch(async error => {
await expect(JSON.parse(error.text)).toStrictEqual(expectedError)
})
})
})
Expand Down

0 comments on commit c134d80

Please sign in to comment.