UNPKG

1.34 kBJavaScriptView Raw
1"use strict";
2
3const path = require('path');
4
5const {
6 ifAnyDep,
7 hasFile,
8 hasPkgProp,
9 fromRoot
10} = require('../utils');
11
12const here = p => path.join(__dirname, p);
13
14const useBuiltInBabelConfig = !hasFile('.babelrc') && !hasPkgProp('babel');
15const ignores = ['/node_modules/', '/fixtures/', '/__tests__/helpers/', '__mocks__'];
16const jestConfig = {
17 roots: [fromRoot('src')],
18 testEnvironment: ifAnyDep(['webpack', 'rollup', 'react'], 'jsdom', 'node'),
19 testURL: 'http://localhost',
20 moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'],
21 collectCoverageFrom: ['src/**/*.+(js|jsx|ts|tsx)'],
22 testMatch: ['**/__tests__/**/*.+(js|jsx|ts|tsx)'],
23 testPathIgnorePatterns: [...ignores],
24 coveragePathIgnorePatterns: [...ignores, 'src/(umd|cjs|esm)-entry.js$'],
25 transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
26 coverageThreshold: {
27 global: {
28 branches: 100,
29 functions: 100,
30 lines: 100,
31 statements: 100
32 }
33 },
34 watchPlugins: [require.resolve('jest-watch-typeahead/filename'), require.resolve('jest-watch-typeahead/testname')]
35};
36
37if (hasFile('tests/setup-env.js')) {
38 jestConfig.setupFilesAfterEnv = [fromRoot('tests/setup-env.js')];
39}
40
41if (useBuiltInBabelConfig) {
42 jestConfig.transform = {
43 '^.+\\.js$': here('./babel-transform')
44 };
45}
46
47module.exports = jestConfig;
\No newline at end of file