Skip to content

Commit

Permalink
infra: properly configure jest for the monorepo setup
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanKovacic committed Apr 8, 2024
1 parent 7e928cb commit 145a991
Show file tree
Hide file tree
Showing 13 changed files with 189 additions and 1,783 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"jest.jestCommandLine": "pnpm run test"
}
8 changes: 5 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module.exports = {
testEnvironment: "node",
// Fun times waiting on pnpm installs inside of CI
testTimeout: 120000,
testRegex: "tests\\/e2e\\/.+test.js",
testPathIgnorePatterns: ["<rootDir>/tests/fixtures/"],
watchPathIgnorePatterns: ["<rootDir>/tests/fixtures/"],
globalSetup: "<rootDir>/tests/create-fixtures.js",
projects: [
"<rootDir>/packages/*/jest.config.js",
"<rootDir>/tests/jest.config.js",
],
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@types/jest": "^27.0.1",
"cross-env": "^7.0.3",
"husky": "^7.0.2",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
Expand All @@ -15,9 +16,8 @@
"rimraf": "^3.0.2"
},
"scripts": {
"clean-tests": "rimraf tests/fixtures && pnpm install",
"test": "pnpm run clean-tests && pnpm run test:e2e",
"test:e2e": "jest",
"test:all": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --all",
"test": "rimraf tests/fixtures && pnpm run test:all",
"format": "prettier . --write",
"prepare": "husky install"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/generator-single-spa/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
testEnvironment: "node",
// Tests in the "src" folder are template tests which should not be run as part of the generator tests
testPathIgnorePatterns: ["<rootDir>/src/"],
};
3 changes: 3 additions & 0 deletions packages/single-spa-web-server-utils/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
5 changes: 5 additions & 0 deletions packages/single-spa-web-server-utils/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/** @type {import('@jest/types').Config.ProjectConfig} */

const config = {
moduleNameMapper: {
"node-fetch": "<rootDir>/__mocks__/node-fetch.js",
"import-map-overrides": "<rootDir>/__mocks__/import-map-overrides.js",
},
transformIgnorePatterns: [
"/node_modules/(?!(node-fetch|lodash|import-map-overrides)/)",
],
transform: {},
clearMocks: true,
};

Expand Down
2 changes: 2 additions & 0 deletions packages/single-spa-web-server-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
"node-fetch": "^2.7.0"
},
"devDependencies": {
"@babel/preset-env": "^7.23.3",
"@jest/globals": "^27.4.6",
"@jest/types": "^27.4.2",
"babel-jest": "^27.5.1",
"cross-env": "^7.0.3",
"jest": "^27.4.7",
"jest-cli": "^27.4.7"
Expand Down
2 changes: 1 addition & 1 deletion packages/single-spa-welcome/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
rootDir: "src",
testEnvironment: "jsdom",
transform: {
"^.+\\.(j|t)sx?$": "babel-jest",
"\\.[jt]sx?$": ["babel-jest", { cwd: __dirname }],
},
moduleNameMapper: {
"\\.(css)$": "identity-obj-proxy",
Expand Down
File renamed without changes.
Loading

0 comments on commit 145a991

Please sign in to comment.