Skip to content

Commit

Permalink
Creating Jest config and setup file (#4141)
Browse files Browse the repository at this point in the history
* Create jest.config.js

* Create jest.setup.js
  • Loading branch information
omsuneri authored Dec 14, 2024
1 parent c27aac7 commit 211981c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
// Use jsdom to simulate a browser environment
testEnvironment: 'jest-environment-jsdom',

// Specify where Jest should look for test files
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],

// Transform JavaScript files using Babel (if needed)
transform: {
'^.+\\.jsx?$': 'babel-jest',
},

// Clear mocks between tests for isolation
clearMocks: true,

// Collect coverage information and specify the directory
collectCoverage: true,
coverageDirectory: 'coverage',

// Specify file extensions Jest will process
moduleFileExtensions: ['js', 'jsx', 'json', 'node'],

// Define any global variables for the tests
globals: {
'window': {},
},
// Set up files to run before tests (e.g., polyfills, setup scripts)
setupFiles: ['./jest.setup.js'], // Optional, if you have a setup file
};
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// A jest.setup.js file is used to run setup code before your tests are executed.

0 comments on commit 211981c

Please sign in to comment.