Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 57 additions & 21 deletions jest.test.config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,65 @@
process.env.ENABLE_NEW_JSX_TRANSFORM = 'true';

/**
* @type {import('@jest/types').Config.ProjectConfig}
* This config uses Jest "projects" to run two test suites in a single
* `pnpm test` invocation, each with its own environment:
*
* - "test" — the main suite (jsdom). Uses the MC app preset which
* sets up window.app, localStorage mocks, etc.
* - "eslint-rules" — custom ESLint rule tests (node). These use ESLint's
* RuleTester which requires `structuredClone` (available
* in Node but not in jsdom) and has no DOM dependencies.
* The MC app preset's setup files also assume jsdom
* (they write to `global.window`), so these tests cannot
* run under the main project.
*
* If you add more custom ESLint rules under
* packages/eslint-config-mc-app/rules/, their *.spec.js files will be
* picked up automatically by the "eslint-rules" project.
*
* @type {import('@jest/types').Config.InitialOptions}
*/

module.exports = {
preset: '@commercetools-frontend/jest-preset-mc-app/typescript',
moduleDirectories: [
'application-templates/',
'custom-views-templates/',
'packages/',
'playground/',
'node_modules/',
projects: [
// Main application test suite — jsdom environment.
{
displayName: 'test',
preset: '@commercetools-frontend/jest-preset-mc-app/typescript',
moduleDirectories: [
'application-templates/',
'custom-views-templates/',
'packages/',
'playground/',
'node_modules/',
],
modulePathIgnorePatterns: [
'.cache',
'build',
'dist',
'public/',
'examples',
'packages-backend/',
],
testPathIgnorePatterns: [
'/node_modules/',
// Excluded here because these tests need the node environment (see below).
'packages/eslint-config-mc-app/rules/',
],
transformIgnorePatterns: [
// Transpile also our local packages as they are only symlinked.
'node_modules/(?!(@commercetools-[frontend|backend]+)/)',
],
testEnvironment: 'jsdom',
},
// Custom ESLint rule tests — node environment, no preset/setup files.
// `transform: {}` disables Babel so the MC app preset's babel-plugin-istanbul
// doesn't conflict with Jest's own coverage instrumentation.
{
displayName: 'eslint-rules',
testEnvironment: 'node',
testMatch: ['<rootDir>/packages/eslint-config-mc-app/rules/**/*.spec.js'],
transform: {},
},
],
modulePathIgnorePatterns: [
'.cache',
'build',
'dist',
'public/',
'examples',
'packages-backend/',
],
transformIgnorePatterns: [
// Transpile also our local packages as they are only symlinked.
'node_modules/(?!(@commercetools-[frontend|backend]+)/)',
],
testEnvironment: 'jsdom',
};
Loading
Loading