forked from strapi/strapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest-preset.front.js
More file actions
128 lines (124 loc) · 4.16 KB
/
Copy pathjest-preset.front.js
File metadata and controls
128 lines (124 loc) · 4.16 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
'use strict';
const path = require('path');
const moduleNameMapper = {
'.*\\.(css|less|styl|scss|sass)$': '@strapi/admin-test-utils/file-mock',
'.*\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ico)$':
'@strapi/admin-test-utils/file-mock',
/**
* we're mapping the following packages to the monorepos node_modules
* so if you link a package e.g. `design-system` the correct dependencies
* are used and the tests run correctly.
**/
'^react$': path.join(__dirname, 'node_modules/react'),
'^react-dom$': path.join(__dirname, 'node_modules/react-dom'),
'^react-router-dom$': path.join(__dirname, 'node_modules/react-router-dom'),
'^styled-components$': path.join(__dirname, 'node_modules/styled-components'),
};
/**
* @type {import('jest').Config}
*/
module.exports = {
rootDir: __dirname,
moduleNameMapper,
/* Tells jest to ignore duplicated manual mock files, such as index.js */
modulePathIgnorePatterns: ['.*__mocks__.*'],
testPathIgnorePatterns: ['node_modules/', 'dist/'],
globalSetup: '@strapi/admin-test-utils/global-setup',
setupFiles: ['@strapi/admin-test-utils/setup'],
setupFilesAfterEnv: ['@strapi/admin-test-utils/after-env'],
testEnvironment: '@strapi/admin-test-utils/environment',
prettierPath: require.resolve('prettier-2'),
transform: {
'^.+\\.m?js(x)?$': [
'@swc/jest',
{
jsc: {
parser: {
jsx: true,
dynamicImport: true,
},
// this should match the minimum supported node.js version
target: 'es2020',
},
},
],
'\\.ts$': [
'@swc/jest',
{
jsc: {
parser: {
syntax: 'typescript',
},
},
},
],
'\\.tsx$': [
'@swc/jest',
{
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
path.join(__dirname, 'fileTransformer.js'),
},
transformIgnorePatterns: [
'node_modules/(?!(react-dnd|dnd-core|react-dnd-html5-backend|@react-dnd|fractional-indexing|msw|@mswjs|until-async|outvariant|strict-event-emitter|headers-polyfill|rettime|@open-draft|is-node-process)/)',
],
testMatch: ['**/tests/**/?(*.)+(spec|test).[jt]s?(x)'],
testEnvironmentOptions: {
url: 'http://localhost:1337/admin',
// MSW v2 ships `msw/node` behind the `node` export condition, but jsdom defaults
// to `browser`. Empty-string condition is the recipe from the MSW migration guide
// (https://mswjs.io/docs/migrations/1.x-to-2.x#frequent-issues) — it falls back to
// the package's `default` export so `msw/node` resolves correctly under Jest+jsdom.
customExportConditions: [''],
},
// Use `jest-watch-typeahead` version 0.6.5. Newest version 1.0.0 does not support jest@26
// Reference: https://github.com/jest-community/jest-watch-typeahead/releases/tag/v1.0.0
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
// NOTE: this doesn't work with projects due to a jest bug, so we also set it
// using jest.setTimeout() in the after-env script
testTimeout: 60 * 1000,
// Coverage configuration for SonarQube
collectCoverage: false, // Will be enabled via CLI flag
collectCoverageFrom: [
'**/*.{js,ts,jsx,tsx}',
'!**/*.d.ts',
'!**/node_modules/**',
'!**/dist/**',
'!**/coverage/**',
'!**/*.config.{js,ts,mjs}',
'!**/jest*.{js,ts}',
'!**/rollup*.{js,ts,mjs}',
'!**/babel*.{js,ts}',
'!**/test/**',
'!**/tests/**',
'!**/__tests__/**',
'!**/*.test.{js,ts,jsx,tsx}',
'!**/*.spec.{js,ts,jsx,tsx}',
'!**/public/**',
'!**/static/**',
],
coverageDirectory: '<rootDir>/coverage',
coverageReporters: ['text', 'lcov', 'html'],
coveragePathIgnorePatterns: [
'<rootDir>/dist/',
'<rootDir>/node_modules/',
'<rootDir>/test/',
'<rootDir>/tests/',
'<rootDir>/__tests__/',
'<rootDir>/coverage/',
'<rootDir>/public/',
'<rootDir>/static/',
],
};