Skip to content

Commit

Permalink
Merge pull request #15809 from RaananW/smallJestImprovements
Browse files Browse the repository at this point in the history
Small changes to jest, including the recommended jest extension
  • Loading branch information
sebavan authored Nov 15, 2024
2 parents c788582 + d7bd15b commit 11b34e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"webhint.vscode-webhint",
"IronGeek.vscode-env",
"firsttris.vscode-jest-runner",
"ms-playwright.playwright"
"ms-playwright.playwright",
"orta.vscode-jest"
]
}
24 changes: 12 additions & 12 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Config } from "@jest/types";
import * as fs from "fs";
import * as path from "path";
import { pathsToModuleNameMapper } from "ts-jest";
import { JestConfigWithTsJest, pathsToModuleNameMapper } from "ts-jest";

// const t = Object.assign(ts_preset, puppeteer_preset);

Expand All @@ -14,22 +14,25 @@ const createProject = (type: string) => {
const tsTestConfigPath = path.resolve(".", "tsconfig.test.json");
const globalSetup = fs.existsSync(setupFileLocation) ? setupFileLocation : undefined;
const setupFilesAfterEnv = fs.existsSync(setupFilesAfterEnvLocation) ? [setupFilesAfterEnvLocation] : undefined;
const returnValue: Partial<Config.ProjectConfig> = {
const returnValue: Partial<JestConfigWithTsJest> = {
displayName: {
name: type,
color: "yellow",
},
testRegex: [`/test/${type}/.*test\\.[tj]sx?$`],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: "<rootDir>/packages/" }) as any,
roots: [path.resolve(".")],
globals: {
"ts-jest": {
isolatedModules: true,
useESM: true,
tsconfig: fs.existsSync(tsTestConfigPath) ? tsTestConfigPath : fs.existsSync(tsConfigPath) ? tsConfigPath : path.resolve(__dirname, "tsconfig.json"),
},
},
setupFilesAfterEnv: ["@alex_neo/jest-expect-message"],
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
isolatedModules: true,
useESM: true,
tsconfig: fs.existsSync(tsTestConfigPath) ? tsTestConfigPath : fs.existsSync(tsConfigPath) ? tsConfigPath : path.resolve(__dirname, "tsconfig.json"),
},
],
},
};
if (globalSetup) {
returnValue.globalSetup = globalSetup;
Expand Down Expand Up @@ -59,9 +62,6 @@ const createProject = (type: string) => {
globalTeardown: "jest-environment-puppeteer/teardown",
testEnvironment: "jest-environment-puppeteer",
preset: "jest-puppeteer",
transform: {
"^.+\\.ts$": "ts-jest",
},
extensionsToTreatAsEsm: [".ts"],
};
} else if (type === "interactions") {
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"extends": "./tsconfig.build.json",

"compilerOptions": {}
"compilerOptions": {
"esModuleInterop": true
}
}

0 comments on commit 11b34e0

Please sign in to comment.