Skip to content

Commit

Permalink
toolchain: Split jest configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
damassi committed Apr 14, 2021
1 parent ce01c20 commit 2d1c1c4
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.cache
.env
.env.staging
.env.shared
Expand Down
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const v2Config = require("./jest.config.v2").projects[0]
const v1Config = require("./jest.config.v1").projects[0]

module.exports = {
projects: [v2Config, v1Config], // this order is necessary
}
14 changes: 14 additions & 0 deletions jest.config.v1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
projects: [
{
displayName: "v1",
// moduleDirectories: ["node_modules"],
moduleFileExtensions: ["js", "jsx", "json", "ts", "tsx"],
setupFilesAfterEnv: ["jest-extended", "<rootDir>/src/test/helper.js"],
testMatch: ["**/v1/**/?(*.)+(test).[jt]s"],
transform: {
"^.+\\.(js|ts)$": "babel-jest",
},
},
],
}
27 changes: 27 additions & 0 deletions jest.config.v2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
projects: [
{
displayName: "v2",
cacheDirectory: ".cache/jest",
coverageDirectory: "coverage",
collectCoverage: true,
coverageReporters: ["lcov", "text-summary"],
moduleFileExtensions: ["js", "jsx", "json", "ts", "tsx"],
testRegex: "(.test)\\.(js|ts)$",
testPathIgnorePatterns: [
"/node_modules/",
"/build/",
"/src/test/helper.js",
"/src/test/utils.js",
"/src/test/gql.js",
"/src/test/__mocks__",
"/src/schema/v1/",
"src/schema/v2/__tests__/ecommerce/",
],
transform: {
"^.+\\.(js|ts)$": "babel-jest",
},
setupFilesAfterEnv: ["jest-extended", "<rootDir>/src/test/helper.js"],
},
],
}
34 changes: 2 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"schema-drift": "babel-node --no-warnings --extensions '.ts,.js' ./scripts/schema-drift.ts",
"start": "yarn run dev",
"test": "yarn type-check && yarn lint && jest",
"test:ci:jest:v1": "yarn jest --config jest.config.v1.js",
"test:ci:jest:v2": "yarn jest --config jest.config.v2.js",
"test:debug": "node --inspect node_modules/.bin/jest --runInBand",
"test:validQueries": "babel-node --extensions '.ts,.js' src/integration/__tests__/runStoredQueryTests.ts",
"type-check": "tsc --noEmit --pretty",
Expand Down Expand Up @@ -151,38 +153,6 @@
"supertest": "3.1.0",
"typescript": "4.2.4"
},
"jest": {
"setupFilesAfterEnv": [
"jest-extended",
"<rootDir>/src/test/helper.js"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/build/",
"/src/test/helper.js",
"/src/test/utils.js",
"/src/test/gql.js",
"/src/test/__mocks__",
"src/schema/v2/__tests__/ecommerce/"
],
"transform": {
"^.+\\.(js|ts)$": "babel-jest"
},
"moduleFileExtensions": [
"js",
"jsx",
"json",
"ts",
"tsx"
],
"testRegex": "(.test)\\.(js|ts)$",
"coverageDirectory": "coverage",
"collectCoverage": true,
"coverageReporters": [
"lcov",
"text-summary"
]
},
"prettier": {
"semi": false,
"singleQuote": false,
Expand Down

0 comments on commit 2d1c1c4

Please sign in to comment.