From 211981c02c36767560d61e8ab31f15e4b1d5ab41 Mon Sep 17 00:00:00 2001 From: omsuneri <142336291+omsuneri@users.noreply.github.com> Date: Sat, 14 Dec 2024 21:56:29 +0530 Subject: [PATCH] Creating Jest config and setup file (#4141) * Create jest.config.js * Create jest.setup.js --- jest.config.js | 29 +++++++++++++++++++++++++++++ jest.setup.js | 1 + 2 files changed, 30 insertions(+) create mode 100644 jest.config.js create mode 100644 jest.setup.js diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000000..648ffa80c5 --- /dev/null +++ b/jest.config.js @@ -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 +}; diff --git a/jest.setup.js b/jest.setup.js new file mode 100644 index 0000000000..1a9ba9dd03 --- /dev/null +++ b/jest.setup.js @@ -0,0 +1 @@ +// A jest.setup.js file is used to run setup code before your tests are executed.