forked from strapi/strapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest-preset.front.js
95 lines (90 loc) · 2.84 KB
/
jest-preset.front.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
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
'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/environment'],
setupFilesAfterEnv: ['@strapi/admin-test-utils/after-env'],
testEnvironment: 'jsdom',
transform: {
'^.+\\.js(x)?$': [
'@swc/jest',
{
env: {
coreJs: '3.33.0',
mode: 'usage',
},
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)/)',
],
testMatch: ['**/tests/**/?(*.)+(spec|test).[jt]s?(x)'],
testEnvironmentOptions: {
url: 'http://localhost:1337/admin',
},
// 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,
};