forked from Shopify/quilt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
53 lines (50 loc) · 1.51 KB
/
jest.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const {readdirSync, existsSync} = require('fs');
const path = require('path');
const moduleNameMapper = getPackageNames().reduce(
(accumulator, name) => {
const scopedName = `@shopify/${name}$`;
accumulator[scopedName] = `<rootDir>/packages/${name}/src/index.ts`;
return accumulator;
},
{
'@shopify/react-effect/server':
'<rootDir>/packages/react-effect/src/server.tsx',
'@shopify/react-async/testing':
'<rootDir>/packages/react-async/src/testing.tsx',
'@shopify/react-html/server':
'<rootDir>/packages/react-html/src/server/index.ts',
'@shopify/react-network/server':
'<rootDir>/packages/react-network/src/server.ts',
},
);
module.exports = {
setupFiles: ['./test/setup.ts'],
setupFilesAfterEnv: ['./test/each-test.ts'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
transform: {
'^.+\\.[t|j]sx?$': 'babel-jest',
'\\.(gql|graphql)$': 'jest-transform-graphql',
},
watchPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/packages/web-worker/.*/fixtures',
],
testRegex: '.*\\.test\\.tsx?$',
testEnvironmentOptions: {
url: 'http://localhost:3000/',
},
coverageDirectory: './coverage/',
collectCoverage: true,
moduleNameMapper,
};
function getPackageNames() {
const packagesPath = path.join(__dirname, 'packages');
return readdirSync(packagesPath).filter(packageName => {
const packageJSONPath = path.join(
packagesPath,
packageName,
'package.json',
);
return existsSync(packageJSONPath);
});
}