forked from Shopify/polaris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsewing-kit.config.ts
50 lines (43 loc) · 1.53 KB
/
sewing-kit.config.ts
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
import {join} from 'path';
import {ConfigurationCallback, Env, Plugins} from '@shopify/sewing-kit';
const tests = join(__dirname, 'tests');
export default function sewingKitConfig(
plugins: Plugins,
env: Env,
): ReturnType<ConfigurationCallback> {
return {
name: 'polaris',
library: true,
plugins: [
plugins.jest((config) => {
config.roots = [join(__dirname, 'src'), join(__dirname, 'tests')];
config.setupFiles.push(join(tests, 'setup.ts'));
// svg transform have to go before the existing transforms so that .svg
// files match our declaration first, and thus run the svg transform,
// instead of matching the file transform
config.transform = {
'\\.svg$': join(__dirname, 'config/jest/transformers/svg.js'),
...config.transform,
};
// Needed because we set js: 'react-native' in our tsconfig to leave the
// transformation up to consuming projects, but within Jest we want to
// transform the jsx content
// eslint-disable-next-line typescript/no-var-requires
const {compilerOptions} = require('./tsconfig.json');
config.globals['ts-jest'].tsConfig = {
...compilerOptions,
jsx: 'react',
};
// Code coverage
config.collectCoverageFrom = [
'src/**/*.{ts,tsx}',
'!src/test-utilities/**/*.*',
'!src/**/index.{ts,tsx}',
'!src/**/*.d.ts',
'!src/**/*.test.{ts,tsx}',
];
return config;
}),
],
};
}