Skip to content

Commit 211981c

Browse files
authored
Creating Jest config and setup file (#4141)
* Create jest.config.js * Create jest.setup.js
1 parent c27aac7 commit 211981c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

jest.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
// Use jsdom to simulate a browser environment
3+
testEnvironment: 'jest-environment-jsdom',
4+
5+
// Specify where Jest should look for test files
6+
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
7+
8+
// Transform JavaScript files using Babel (if needed)
9+
transform: {
10+
'^.+\\.jsx?$': 'babel-jest',
11+
},
12+
13+
// Clear mocks between tests for isolation
14+
clearMocks: true,
15+
16+
// Collect coverage information and specify the directory
17+
collectCoverage: true,
18+
coverageDirectory: 'coverage',
19+
20+
// Specify file extensions Jest will process
21+
moduleFileExtensions: ['js', 'jsx', 'json', 'node'],
22+
23+
// Define any global variables for the tests
24+
globals: {
25+
'window': {},
26+
},
27+
// Set up files to run before tests (e.g., polyfills, setup scripts)
28+
setupFiles: ['./jest.setup.js'], // Optional, if you have a setup file
29+
};

jest.setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// A jest.setup.js file is used to run setup code before your tests are executed.

0 commit comments

Comments
 (0)