Skip to content

Commit f0d4851

Browse files
committed
jest configuration
1 parent c7beff9 commit f0d4851

File tree

4 files changed

+706
-601
lines changed

4 files changed

+706
-601
lines changed

jest.config.js

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
// For a detailed explanation regarding each configuration property, visit:
2-
// https://jestjs.io/docs/en/configuration.html
1+
const aliases = require("./build/aliases");
2+
3+
console.log(aliases);
4+
5+
const moduleNameMapper = Object.keys(aliases).reduce((acc, alias) => {
6+
console.log(alias, aliases[alias]);
7+
acc[`${alias}/(.*)$`] = `<rootDir>${aliases[alias].slice(1)}/$1`;
8+
return acc;
9+
}, {});
10+
11+
moduleNameMapper["common/(.*)$"] = "<rootDir>/src/common/$1";
12+
console.log(moduleNameMapper);
313

414
module.exports = {
515
// All imported modules in your tests should be mocked automatically
@@ -132,8 +142,19 @@ module.exports = {
132142
// snapshotSerializers: [],
133143

134144
// The test environment that will be used for testing
135-
testEnvironment: "node",
145+
testEnvironment: "jsdom",
146+
147+
preset: "ts-jest",
148+
149+
testPathIgnorePatterns: ["/dist/", "/node_modules/", "/bundled/"],
150+
151+
moduleNameMapper,
136152

153+
// test: {
154+
// '@ahoopen/core(.*)$': '<rootDir>/packages/./core/src/$1',
155+
// '@ahoopen/utils(.*)$': '<rootDir>/packages/./utils/src/$1',
156+
// '@ahoopen/web(.*)$': '<rootDir>/packages/./web/src/$1'
157+
// },
137158
// Options that will be passed to the testEnvironment
138159
// testEnvironmentOptions: {},
139160

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
"@types/d3-ease": "^3.0.0",
136136
"@types/deep-diff": "^1.0.1",
137137
"@types/express": "^4.17.13",
138-
"@types/jest": "^27.0.3",
138+
"@types/jest": "^29.0.3",
139139
"@types/libnpmsearch": "^2.0.3",
140140
"@types/lodash.debounce": "^4.0.6",
141141
"@types/lodash.get": "^4.4.6",
@@ -169,12 +169,14 @@
169169
"eslint-plugin-react": "^7.21.5",
170170
"eslint-plugin-react-hooks": "^4.2.0",
171171
"glslify-loader": "^2.0.0",
172-
"jest": "^27.2.4",
172+
"jest": "^29.0.3",
173+
"jest-environment-jsdom": "^29.0.3",
173174
"prettier": "^2.4.1",
174175
"raw-loader": "^4.0.2",
175176
"reflect-metadata": "^0.1.13",
176177
"rimraf": "^3.0.2",
177178
"source-map-support": "^0.5.19",
179+
"ts-jest": "^29.0.1",
178180
"ts-node": "^10.9.1",
179181
"url-loader": "^4.1.1",
180182
"worker-loader": "^2.0.0"
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { describe, it } from "@jest/globals";
2+
import processStore from "./process-store";
3+
describe("ProcessStore", () => {
4+
5+
it("should have empty processes on init", () => {
6+
7+
expect(processStore().processes).toHaveLength(0);
8+
9+
});
10+
11+
12+
});

0 commit comments

Comments
 (0)