-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Jest to work across entire monorepo
- Loading branch information
Showing
10 changed files
with
71 additions
and
30 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,4 @@ | ||
module.exports = { | ||
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'], | ||
plugins: ['@babel/plugin-transform-runtime'], | ||
}; |
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,9 @@ | ||
// A base config for all our Jest test projects to use | ||
module.exports = { | ||
testEnvironment: 'node', | ||
verbose: true, | ||
setupFiles: ['<rootDir>/jest.setup.js'], | ||
coverageDirectory: '<rootDir>/coverage', | ||
moduleDirectories: ['node_modules'], | ||
automock: false, | ||
}; |
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,13 @@ | ||
const baseConfig = require('./jest.config.base'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
projects: [ | ||
// Our legacy backend tests, slowly being migrated to microservices | ||
'<rootDir>/test/jest.config.js', | ||
// Our new microservices | ||
'<rootDir>/src/api/**/jest.config.js', | ||
// Our front-end | ||
'<rootDir>/src/web/jest.config.js', | ||
], | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* global jest */ | ||
const fetch = require('jest-fetch-mock'); | ||
|
||
jest.setMock('node-fetch', fetch); |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
const baseConfig = require('../../../jest.config.base'); | ||
|
||
module.exports = { | ||
testPathIgnorePatterns: ['/node_modules/'], | ||
testMatch: ['<rootDir>/test/unit/**/*.test.js'], | ||
verbose: true, | ||
...baseConfig, | ||
rootDir: '../../..', | ||
setupFiles: ['<rootDir>/jest.setup.js', '<rootDir>/src/api/auth/jest.setup.js'], | ||
testMatch: ['<rootDir>/src/api/auth/test/unit/**/*.test.js'], | ||
collectCoverageFrom: ['<rootDir>/src/api/auth/server.js', '<rootDir>/src/api/auth/src/**/*.js'], | ||
}; |
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,9 @@ | ||
// NOTE: you need to run the auth and login services in docker for these to work | ||
|
||
const path = require('path'); | ||
// NOTE: you need to copy ../env.development to ../.env and run services | ||
const result = require('dotenv').config({ path: path.join(__dirname, '../.env') }); | ||
|
||
if (result.error) { | ||
throw result.error; | ||
} |
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,10 @@ | ||
const baseConfig = require('../../jest.config.base'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
preset: 'ts-jest', | ||
rootDir: '../..', | ||
testMatch: ['<rootDir>/src/web/src/**/*.test.{ts,tsx}'], | ||
testPathIgnorePatterns: ['<rootDir>/src/web/.next', '<rootDir>/src/web/out'], | ||
collectCoverageFrom: ['src/**/*{ts,tsx}'], | ||
}; |
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,8 @@ | ||
const baseConfig = require('../jest.config.base'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
rootDir: '../', | ||
testMatch: ['<rootDir>/test/**/*.test.js'], | ||
collectCoverageFrom: ['<rootDir>/src/backend/**/*.js'], | ||
}; |