-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.jest.config.js
52 lines (42 loc) · 1.45 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
module.exports = {
// Use the Backstage configuration as a base with overrides
rootDir: '.',
roots: ['<rootDir>/src'],
// Setup files run before each test
setupFilesAfterEnv: ['<rootDir>/jest/setupTests.js'],
// Transform esm modules from node_modules
transformIgnorePatterns: [
'/node_modules/(?!(@backstage|react-use|@material-ui|lodash-es|react-syntax-highlighter))',
],
// Handle specific file transformations
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'ts-jest',
},
// Modules that don't play well with Jest's module system
moduleNameMapper: {
// Handle CSS imports
'\\.css$': 'identity-obj-proxy',
// Handle assets imports
'\\.(jpg|jpeg|png|gif|svg)$': '<rootDir>/jest/fileMock.js',
// Handle module aliases
'^url$': require.resolve('url/'),
'^buffer$': require.resolve('buffer/'),
'^util$': require.resolve('util/'),
'^stream$': require.resolve('stream-browserify'),
'^crypto$': require.resolve('crypto-browserify'),
// React DOM/client mock for compatibility
'^react-dom/client$': '<rootDir>/jest/mocks/reactDomClient.js'
},
// Test environment
testEnvironment: 'jsdom',
// Coverage settings
collectCoverageFrom: [
'src/**/*.{js,jsx,ts,tsx}',
'!src/**/*.d.ts',
'!src/**/*.test.{js,jsx,ts,tsx}',
],
// Helpful settings for modern tests
testMatch: ['**/?(*.)+(spec|test).+(ts|tsx|js|jsx)'],
verbose: true,
testTimeout: 30000,
};