Files
pnpm/__utils__/jest-config/config.js
Brandon Cheng 1a5b5beea2 build: replace ts-jest with simple transformer (#10579)
* test: use `import type` in more places

Several tests are failing because a module isn't being mocked. This is
due to the mocked module being imported before the mock being set up.

Switching to `import type` should elide the import fully.

* build: replace ts-jest with simple transformer

* chore: remove `ts-jest`

* chore: remove babel dependencies from root project

* ci: use Node.js 22.13.0 (instead of 22.12.0)

Node.js 22.13.0 introduces the `stripTypeScriptTypes` function

* fix: copilot feedback
2026-02-09 11:35:22 +01:00

35 lines
1.3 KiB
JavaScript

import path from 'path'
const config = {
resolver: path.join(import.meta.dirname, 'node_modules/ts-jest-resolver'),
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.tsx?$': path.join(import.meta.dirname, 'jest.transform.js'),
},
testMatch: ["**/test/**/*.[jt]s?(x)", "**/src/**/*.test.ts"],
testEnvironment: "node",
collectCoverage: true,
coveragePathIgnorePatterns: ["/node_modules/"],
testPathIgnorePatterns: ["/fixtures/", "/__fixtures__/", "<rootDir>/test/utils/.+"],
modulePathIgnorePatterns: ['\/__fixtures__\/.*'],
testTimeout: 4 * 60 * 1000, // 4 minutes
setupFilesAfterEnv: [path.join(import.meta.dirname, "setupFilesAfterEnv.js")],
maxWorkers: "50%",
}
if (process.env.PNPM_SCRIPT_SRC_DIR) {
const pathAsArr = process.env.PNPM_SCRIPT_SRC_DIR.split(path.sep)
const packageName = pathAsArr[pathAsArr.length - 1]
config.cacheDirectory = path.join(import.meta.dirname, ".jest-cache", packageName)
}
// We are running test script from pnpm command, this seems to confuse tests
// Clean up env from pnpm variables so that nested pnpm runs won't get affected on config read
for (const key of Object.keys(process.env)) {
if (/^p?npm_(config|package|lifecycle|node|command|execpath)(_|$)/ui.test(key)) {
delete process.env[key]
}
}
export default config