|
1 | | -module.exports = { |
2 | | - testMatch: [ |
3 | | - "**/test/**/*.+(ts|tsx|js)", |
4 | | - "**/src/**/(*.)+(spec|test).+(ts|tsx|js)", |
5 | | - ], |
6 | | - transform: { |
7 | | - "^.+\\.(ts|tsx)$": "ts-jest", |
8 | | - }, |
9 | | - // testPathIgnorePatterns: ["./examples"], |
10 | | - testEnvironment: "miniflare", |
11 | | - testEnvironmentOptions: { |
12 | | - /* |
13 | | - bindings: { |
14 | | - __STATIC_CONTENT: { |
15 | | - get: (key) => { |
16 | | - const table = { 'index.abcdef.index': 'This is index' } |
17 | | - return table[key] |
18 | | - }, |
19 | | - }, |
20 | | - __STATIC_CONTENT_MANIFEST: JSON.stringify({ |
21 | | - 'index.index': 'index.abcdef.index', |
22 | | - }), |
23 | | - }, |
24 | | - kvNamespaces: ['TEST_NAMESPACE'], |
25 | | - */ |
26 | | - }, |
| 1 | +const { resolve } = require("path"); |
| 2 | +const { pathsToModuleNameMapper } = require("ts-jest"); |
| 3 | + |
| 4 | +const pkg = require("./package.json"); |
| 5 | +const tsconfig = require("./tsconfig.json"); |
| 6 | +const CI = !!process.env.CI; |
| 7 | + |
| 8 | +module.exports = () => { |
| 9 | + return { |
| 10 | + displayName: pkg.name, |
| 11 | + rootDir: __dirname, |
| 12 | + preset: "ts-jest", |
| 13 | + testEnvironment: "miniflare", |
| 14 | + restoreMocks: true, |
| 15 | + reporters: ["default"], |
| 16 | + modulePathIgnorePatterns: ["dist"], |
| 17 | + moduleNameMapper: pathsToModuleNameMapper( |
| 18 | + tsconfig.compilerOptions.paths || [], |
| 19 | + { |
| 20 | + prefix: `./`, |
| 21 | + } |
| 22 | + ), |
| 23 | + cacheDirectory: resolve( |
| 24 | + __dirname, |
| 25 | + `${CI ? "" : "node_modules/"}.cache/jest` |
| 26 | + ), |
| 27 | + collectCoverage: false, |
| 28 | + }; |
27 | 29 | }; |
0 commit comments