Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infra: reconfigure jest #402

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/unlucky-suits-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this .changeset.

"generator-single-spa": major
---

remove "husky" from create-single-spa templates
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
- run: git checkout main && git checkout $GITHUB_SHA
- run: pnpm install --frozen-lockfile
- run: pnpm changeset status
- run: pnpm test --recursive
- run: pnpm test
- run: pnpm run --recursive lint
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/"],
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ module.exports = class SingleSpaReactGenerator extends PnpmGenerator {
this.destinationPath(".gitignore"),
this.options
);
this.fs.copyTpl(
this.templatePath(`../../common-templates/.husky/pre-commit`),
this.destinationPath(`.husky/pre-commit`),
this.options
);

if (this.options.typescript) {
this.fs.copyTpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"check-format": "prettier --check .",
"test": "cross-env BABEL_ENV=test jest",
"watch-tests": "cross-env BABEL_ENV=test jest --watch",
"prepare": "husky install",
"coverage": "cross-env BABEL_ENV=test jest --coverage"
},
"devDependencies": {
Expand All @@ -30,7 +29,6 @@
"eslint-config-prettier": "^8.3.0",
"eslint-config-react-important-stuff": "^3.0.0",
"eslint-plugin-prettier": "^3.4.1",
"husky": "^7.0.2",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ module.exports = class SingleSpaRootConfigGenerator extends PnpmGenerator {
this.options
);

this.fs.copyTpl(
this.templatePath(`../../common-templates/.husky/pre-commit`),
this.destinationPath(`.husky/pre-commit`),
this.options
);

this.fs.copyTpl(
this.templatePath(".eslintrc.ejs"),
this.destinationPath(".eslintrc"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"test": "cross-env BABEL_ENV=test jest --passWithNoTests",
"format": "prettier --write .",
"check-format": "prettier --check .",
"prepare": "husky install",
"build": "concurrently <%- packageManager %>:build:*",
"build:webpack": "webpack --mode=production"
},
Expand All @@ -23,7 +22,6 @@
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
"html-webpack-plugin": "^5.3.2",
"husky": "^7.0.2",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"prettier": "^2.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ module.exports = class SingleSpaSvelteGenerator extends PnpmGenerator {
this.destinationPath(`.gitignore`),
this.options
);
this.fs.copyTpl(
this.templatePath(`../../common-templates/.husky/pre-commit`),
this.destinationPath(`.husky/pre-commit`),
this.options
);
this.fs.copyTpl(
this.templatePath(`.prettierignore`),
this.destinationPath(`.prettierignore`),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"start": "rollup -c -w",
"serve": "sirv dist -c",
"test": "jest",
"prepare": "husky install",
"format": "prettier --write --plugin-search-dir=. .",
"check-format": "prettier --plugin-search-dir=. --check ."
},
Expand All @@ -27,7 +26,7 @@
"rollup-plugin-svelte": "^7.1.0",
"rollup-plugin-terser": "^7.0.2",
"svelte": "^3.42.3",
"svelte-jester": "^2.0.0"
"svelte-jester": "^2.3.2"
},
"dependencies": {
"single-spa-svelte": "^2.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ module.exports = class SingleSpaUtilModuleGenerator extends PnpmGenerator {
this.destinationPath(".gitignore"),
this.options
);
this.fs.copyTpl(
this.templatePath(`../../common-templates/.husky/pre-commit`),
this.destinationPath(`.husky/pre-commit`),
this.options
);
this.fs.copyTpl(
this.templatePath("webpack.config.js"),
this.destinationPath("webpack.config.js"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"lint": "eslint src --ext js<% if (typescript) { %>,ts,tsx<% } %>",
"format": "prettier --write .",
"check-format": "prettier --check .",
"prepare": "husky install",
"test": "cross-env BABEL_ENV=test jest --passWithNoTests",
"watch-tests": "cross-env BABEL_ENV=test jest --watch",
"coverage": "cross-env BABEL_ENV=test jest --coverage"
Expand All @@ -27,7 +26,6 @@
"eslint-config-prettier": "^8.3.0",
"eslint-config-important-stuff": "^1.1.0",
"eslint-plugin-prettier": "^3.4.1",
"husky": "^7.0.2",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
Expand Down
1 change: 0 additions & 1 deletion packages/generator-single-spa/test/react.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@ describe("generator-single-spa-react", () => {
});
runResult.assertFile("jest.config.js");
runResult.assertFile("babel.config.json");
runResult.assertFile(".husky/pre-commit");
});
});
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
Loading
Loading