diff --git a/apps/react-18-tests-v9/jest.config.js b/apps/react-18-tests-v9/jest.config.js index 1f8b56ac7f0fe..589684f5c50f6 100644 --- a/apps/react-18-tests-v9/jest.config.js +++ b/apps/react-18-tests-v9/jest.config.js @@ -13,13 +13,7 @@ module.exports = { '^react-dom$': '/node_modules/react-dom', }, transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/apps/ssr-tests-v9/jest.config.js b/apps/ssr-tests-v9/jest.config.js index c7b8c1451c4d8..615664666b55b 100644 --- a/apps/ssr-tests-v9/jest.config.js +++ b/apps/ssr-tests-v9/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'ssr-tests-v9', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, testEnvironment: 'node', coverageDirectory: './coverage', diff --git a/apps/theming-designer/project.json b/apps/theming-designer/project.json index 4ab7f1e294ae5..876c7d22633b2 100644 --- a/apps/theming-designer/project.json +++ b/apps/theming-designer/project.json @@ -2,5 +2,6 @@ "name": "theming-designer", "$schema": "../../node_modules/nx/schemas/project-schema.json", "projectType": "application", - "implicitDependencies": [] + "implicitDependencies": [], + "tags": ["v8"] } diff --git a/apps/vr-tests-react-components/jest.config.js b/apps/vr-tests-react-components/jest.config.js index 58bd73a8c051c..d6d71f1d5c677 100644 --- a/apps/vr-tests-react-components/jest.config.js +++ b/apps/vr-tests-react-components/jest.config.js @@ -7,12 +7,6 @@ module.exports = { displayName: 'vr-tests-react-components', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, }; diff --git a/package.json b/package.json index 54c00ea0c9383..2b8131a6bfff8 100644 --- a/package.json +++ b/package.json @@ -125,6 +125,7 @@ "@swc/cli": "0.3.14", "@swc/core": "1.5.7", "@swc/helpers": "0.5.1", + "@swc/jest": "0.2.36", "@testing-library/dom": "8.11.3", "@testing-library/jest-dom": "5.16.5", "@testing-library/react": "12.1.2", @@ -138,7 +139,6 @@ "@types/chrome-remote-interface": "0.30.0", "@types/circular-dependency-plugin": "5.0.5", "@types/copy-webpack-plugin": "10.1.0", - "@types/dedent": "0.7.0", "@types/doctrine": "0.0.5", "@types/ejs": "3.1.2", "@types/enzyme": "3.10.7", @@ -213,7 +213,7 @@ "cypress-real-events": "1.11.0", "cypress-storybook": "0.5.1", "danger": "^11.0.0", - "dedent": "0.7.0", + "dedent": "1.2.0", "del": "6.0.0", "doctoc": "2.0.1", "doctrine": "3.0.0", diff --git a/packages/react-components/babel-preset-global-context/jest.config.js b/packages/react-components/babel-preset-global-context/jest.config.js index 82cd532a46841..af23755d8bc08 100644 --- a/packages/react-components/babel-preset-global-context/jest.config.js +++ b/packages/react-components/babel-preset-global-context/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'babel-preset-global-context', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/babel-preset-storybook-full-source/jest.config.js b/packages/react-components/babel-preset-storybook-full-source/jest.config.js index b2c8dca1b0a8d..123d646708d72 100644 --- a/packages/react-components/babel-preset-storybook-full-source/jest.config.js +++ b/packages/react-components/babel-preset-storybook-full-source/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'babel-preset-storybook-full-source', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/global-context/jest.config.js b/packages/react-components/global-context/jest.config.js index edabe8d65358b..d8b4384a280e0 100644 --- a/packages/react-components/global-context/jest.config.js +++ b/packages/react-components/global-context/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'global-context', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/keyboard-keys/jest.config.js b/packages/react-components/keyboard-keys/jest.config.js index 0e329695514a0..757f1c501d40c 100644 --- a/packages/react-components/keyboard-keys/jest.config.js +++ b/packages/react-components/keyboard-keys/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'keyboard-keys', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/priority-overflow/jest.config.js b/packages/react-components/priority-overflow/jest.config.js index 4e29b28bbb663..3885e65adcbb4 100644 --- a/packages/react-components/priority-overflow/jest.config.js +++ b/packages/react-components/priority-overflow/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'priority-overflow', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-accordion/library/jest.config.js b/packages/react-components/react-accordion/library/jest.config.js index 270c7f58c7e1a..709e4a2a4da59 100644 --- a/packages/react-components/react-accordion/library/jest.config.js +++ b/packages/react-components/react-accordion/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-accordion', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-aria/library/jest.config.js b/packages/react-components/react-aria/library/jest.config.js index 0ebdbf86df620..57deee862a091 100644 --- a/packages/react-components/react-aria/library/jest.config.js +++ b/packages/react-components/react-aria/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-aria', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-avatar/library/jest.config.js b/packages/react-components/react-avatar/library/jest.config.js index de3440173a458..dc18a8504c421 100644 --- a/packages/react-components/react-avatar/library/jest.config.js +++ b/packages/react-components/react-avatar/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-avatar', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-badge/library/jest.config.js b/packages/react-components/react-badge/library/jest.config.js index 802a89d2a381e..9774395ae9a23 100644 --- a/packages/react-components/react-badge/library/jest.config.js +++ b/packages/react-components/react-badge/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-badge', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-breadcrumb/library/jest.config.js b/packages/react-components/react-breadcrumb/library/jest.config.js index ced5fbbf09179..3e1bdbdcd121b 100644 --- a/packages/react-components/react-breadcrumb/library/jest.config.js +++ b/packages/react-components/react-breadcrumb/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-breadcrumb', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-button/library/jest.config.js b/packages/react-components/react-button/library/jest.config.js index 12f9f17c8c48f..6d295e622d5f8 100644 --- a/packages/react-components/react-button/library/jest.config.js +++ b/packages/react-components/react-button/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-button', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-calendar-compat/library/jest.config.js b/packages/react-components/react-calendar-compat/library/jest.config.js index e86a78d994b07..f6ebe01a386f1 100644 --- a/packages/react-components/react-calendar-compat/library/jest.config.js +++ b/packages/react-components/react-calendar-compat/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-calendar-compat', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-card/library/jest.config.js b/packages/react-components/react-card/library/jest.config.js index 4f2b6b7da7966..818a6fd0a53f6 100644 --- a/packages/react-components/react-card/library/jest.config.js +++ b/packages/react-components/react-card/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-card', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-carousel-preview/library/jest.config.js b/packages/react-components/react-carousel-preview/library/jest.config.js index 93fdf7d49c0c1..98e0e6204880b 100644 --- a/packages/react-components/react-carousel-preview/library/jest.config.js +++ b/packages/react-components/react-carousel-preview/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-carousel-preview', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-carousel-preview/library/src/components/Carousel/Carousel.test.tsx b/packages/react-components/react-carousel-preview/library/src/components/Carousel/Carousel.test.tsx index 3e86e68073187..605fd226a02e1 100644 --- a/packages/react-components/react-carousel-preview/library/src/components/Carousel/Carousel.test.tsx +++ b/packages/react-components/react-carousel-preview/library/src/components/Carousel/Carousel.test.tsx @@ -4,6 +4,7 @@ import { isConformant } from '../../testing/isConformant'; import { Carousel } from './Carousel'; jest.mock('embla-carousel', () => ({ + __esModule: true, default: () => ({ on: jest.fn(), off: jest.fn(), diff --git a/packages/react-components/react-checkbox/library/jest.config.js b/packages/react-components/react-checkbox/library/jest.config.js index ff883d8163c69..99ac23722e12f 100644 --- a/packages/react-components/react-checkbox/library/jest.config.js +++ b/packages/react-components/react-checkbox/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-checkbox', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-color-picker-preview/library/jest.config.js b/packages/react-components/react-color-picker-preview/library/jest.config.js index 3ff3797baa2a2..28c4aba097cc5 100644 --- a/packages/react-components/react-color-picker-preview/library/jest.config.js +++ b/packages/react-components/react-color-picker-preview/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-color-picker-preview', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-colorpicker-compat/jest.config.js b/packages/react-components/react-colorpicker-compat/jest.config.js index db62c9c9ca175..76e2e0cbe6b4f 100644 --- a/packages/react-components/react-colorpicker-compat/jest.config.js +++ b/packages/react-components/react-colorpicker-compat/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-colorpicker-compat', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-combobox/library/jest.config.js b/packages/react-components/react-combobox/library/jest.config.js index 99bdc57c3d634..c37f332f562de 100644 --- a/packages/react-components/react-combobox/library/jest.config.js +++ b/packages/react-components/react-combobox/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-combobox', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-components/jest.config.js b/packages/react-components/react-components/jest.config.js index 5379cd13aea97..094414a883979 100644 --- a/packages/react-components/react-components/jest.config.js +++ b/packages/react-components/react-components/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-components', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-conformance-griffel/jest.config.js b/packages/react-components/react-conformance-griffel/jest.config.js index 151aee01caed7..b6903810fa45d 100644 --- a/packages/react-components/react-conformance-griffel/jest.config.js +++ b/packages/react-components/react-conformance-griffel/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-conformance-griffel', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-context-selector/jest.config.js b/packages/react-components/react-context-selector/jest.config.js index 5e5bcd3073aa9..61d20ddfe16b4 100644 --- a/packages/react-components/react-context-selector/jest.config.js +++ b/packages/react-components/react-context-selector/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-context-selector', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-datepicker-compat/library/jest.config.js b/packages/react-components/react-datepicker-compat/library/jest.config.js index b772f03680d3e..f78b4bb2bdb9c 100644 --- a/packages/react-components/react-datepicker-compat/library/jest.config.js +++ b/packages/react-components/react-datepicker-compat/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-datepicker-compat', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-dialog/library/jest.config.js b/packages/react-components/react-dialog/library/jest.config.js index 86a9742529735..9bb2d9dde732d 100644 --- a/packages/react-components/react-dialog/library/jest.config.js +++ b/packages/react-components/react-dialog/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-dialog', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-divider/library/jest.config.js b/packages/react-components/react-divider/library/jest.config.js index 19aa05639c341..e54733aa0d7ce 100644 --- a/packages/react-components/react-divider/library/jest.config.js +++ b/packages/react-components/react-divider/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-divider', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-drawer/library/jest.config.js b/packages/react-components/react-drawer/library/jest.config.js index 76a2433e00b6e..30599cabbbac9 100644 --- a/packages/react-components/react-drawer/library/jest.config.js +++ b/packages/react-components/react-drawer/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-drawer', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-field/library/jest.config.js b/packages/react-components/react-field/library/jest.config.js index c82d11aff4fa0..40140f5bad8a8 100644 --- a/packages/react-components/react-field/library/jest.config.js +++ b/packages/react-components/react-field/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-field', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-icons-compat/library/jest.config.js b/packages/react-components/react-icons-compat/library/jest.config.js index a045910fd15fc..a2f259c7b7791 100644 --- a/packages/react-components/react-icons-compat/library/jest.config.js +++ b/packages/react-components/react-icons-compat/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-icons-compat', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-image/library/jest.config.js b/packages/react-components/react-image/library/jest.config.js index bd72d12ff0ced..1228d0798c7e2 100644 --- a/packages/react-components/react-image/library/jest.config.js +++ b/packages/react-components/react-image/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-image', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-infolabel/library/jest.config.js b/packages/react-components/react-infolabel/library/jest.config.js index a994f2b5cc235..c871bda7ac9f7 100644 --- a/packages/react-components/react-infolabel/library/jest.config.js +++ b/packages/react-components/react-infolabel/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-infolabel', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-input/library/jest.config.js b/packages/react-components/react-input/library/jest.config.js index bf5483782926f..699e1f6ec8e8d 100644 --- a/packages/react-components/react-input/library/jest.config.js +++ b/packages/react-components/react-input/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-input', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-jsx-runtime/jest.config.js b/packages/react-components/react-jsx-runtime/jest.config.js index e5cca691680a9..f5ec29eee00d7 100644 --- a/packages/react-components/react-jsx-runtime/jest.config.js +++ b/packages/react-components/react-jsx-runtime/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-jsx-runtime', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-keytips-preview/library/jest.config.js b/packages/react-components/react-keytips-preview/library/jest.config.js index 8717bca1e1192..e3df3d434bcfe 100644 --- a/packages/react-components/react-keytips-preview/library/jest.config.js +++ b/packages/react-components/react-keytips-preview/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-keytips-preview', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-label/library/jest.config.js b/packages/react-components/react-label/library/jest.config.js index b52897645999d..53f7c7b70ea8b 100644 --- a/packages/react-components/react-label/library/jest.config.js +++ b/packages/react-components/react-label/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-label', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-link/library/jest.config.js b/packages/react-components/react-link/library/jest.config.js index de35b54e2c5e5..fba3cb18a026f 100644 --- a/packages/react-components/react-link/library/jest.config.js +++ b/packages/react-components/react-link/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-link', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-list-preview/library/jest.config.js b/packages/react-components/react-list-preview/library/jest.config.js index a4a49feec6f17..f6333c979a2ce 100644 --- a/packages/react-components/react-list-preview/library/jest.config.js +++ b/packages/react-components/react-list-preview/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-list-preview', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-menu/library/jest.config.js b/packages/react-components/react-menu/library/jest.config.js index 1d424c1a2b85f..9bc6e63b6603e 100644 --- a/packages/react-components/react-menu/library/jest.config.js +++ b/packages/react-components/react-menu/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-menu', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-message-bar/library/jest.config.js b/packages/react-components/react-message-bar/library/jest.config.js index 798b5570b4aed..2669112fea23b 100644 --- a/packages/react-components/react-message-bar/library/jest.config.js +++ b/packages/react-components/react-message-bar/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-message-bar', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-migration-v0-v9/jest.config.js b/packages/react-components/react-migration-v0-v9/jest.config.js index 9425868ae0b1d..b3eb7b68d9f59 100644 --- a/packages/react-components/react-migration-v0-v9/jest.config.js +++ b/packages/react-components/react-migration-v0-v9/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-migration-v0-v9', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-migration-v8-v9/jest.config.js b/packages/react-components/react-migration-v8-v9/jest.config.js index 167a0cab65630..60d0d13c1f7f5 100644 --- a/packages/react-components/react-migration-v8-v9/jest.config.js +++ b/packages/react-components/react-migration-v8-v9/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-migration-v8-v9', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-motion-components-preview/library/jest.config.js b/packages/react-components/react-motion-components-preview/library/jest.config.js index b06f29e80fdc5..4b0d5f8d848f1 100644 --- a/packages/react-components/react-motion-components-preview/library/jest.config.js +++ b/packages/react-components/react-motion-components-preview/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-motion-components-preview', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-motion-preview/library/jest.config.js b/packages/react-components/react-motion-preview/library/jest.config.js index bd26963f1c5dd..dc5087f49bf2b 100644 --- a/packages/react-components/react-motion-preview/library/jest.config.js +++ b/packages/react-components/react-motion-preview/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-motion-preview', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-motion-preview/library/src/hooks/useMotionClassNames.test.ts b/packages/react-components/react-motion-preview/library/src/hooks/useMotionClassNames.test.ts index 0bbbcd9f38869..642673015c1f1 100644 --- a/packages/react-components/react-motion-preview/library/src/hooks/useMotionClassNames.test.ts +++ b/packages/react-components/react-motion-preview/library/src/hooks/useMotionClassNames.test.ts @@ -1,17 +1,21 @@ import { renderHook } from '@testing-library/react-hooks'; import { useMotionClassNames } from './useMotionClassNames'; -import * as reducedMotionStyles from '../styles/useReducedMotionStyles.styles'; +import { useReducedMotionStyles } from '../styles/useReducedMotionStyles.styles'; import { getDefaultMotionState, MotionState } from './useMotion'; +jest.mock('../styles/useReducedMotionStyles.styles', () => { + return { + useReducedMotionStyles: jest.fn(), + }; +}); + describe('useMotionClassNames', () => { - let useReducedMotionStylesMock: jest.SpyInstance; + const useReducedMotionStylesMock = useReducedMotionStyles as jest.Mock; let consoleWarnMock: jest.SpyInstance; beforeEach(() => { - useReducedMotionStylesMock = jest.spyOn(reducedMotionStyles, 'useReducedMotionStyles').mockReturnValue({ - reduced: 'reduced', - }); + useReducedMotionStylesMock.mockReturnValue({ reduced: 'reduced' }); consoleWarnMock = jest.spyOn(console, 'warn').mockImplementation(message => message); }); diff --git a/packages/react-components/react-motion/library/jest.config.js b/packages/react-components/react-motion/library/jest.config.js index 1741f7a7749aa..5a71c159afce6 100644 --- a/packages/react-components/react-motion/library/jest.config.js +++ b/packages/react-components/react-motion/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-motion', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-nav-preview/library/jest.config.js b/packages/react-components/react-nav-preview/library/jest.config.js index e9b944b5c8b7b..5c58c51d21619 100644 --- a/packages/react-components/react-nav-preview/library/jest.config.js +++ b/packages/react-components/react-nav-preview/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-nav-preview', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-overflow/library/jest.config.js b/packages/react-components/react-overflow/library/jest.config.js index 9033b4669fafc..2993091e84b41 100644 --- a/packages/react-components/react-overflow/library/jest.config.js +++ b/packages/react-components/react-overflow/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-overflow', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-persona/library/jest.config.js b/packages/react-components/react-persona/library/jest.config.js index 02978ea91303d..bad8ac27c7cbe 100644 --- a/packages/react-components/react-persona/library/jest.config.js +++ b/packages/react-components/react-persona/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-persona', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-popover/library/jest.config.js b/packages/react-components/react-popover/library/jest.config.js index 99cb33b442241..ae5ce8aeee59a 100644 --- a/packages/react-components/react-popover/library/jest.config.js +++ b/packages/react-components/react-popover/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-popover', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-portal-compat-context/jest.config.js b/packages/react-components/react-portal-compat-context/jest.config.js index e24f0b8bfbfc5..51ee0af9b27e6 100644 --- a/packages/react-components/react-portal-compat-context/jest.config.js +++ b/packages/react-components/react-portal-compat-context/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-portal-compat-context', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-portal-compat/jest.config.js b/packages/react-components/react-portal-compat/jest.config.js index 307eb9b8024cd..c609a27cf8344 100644 --- a/packages/react-components/react-portal-compat/jest.config.js +++ b/packages/react-components/react-portal-compat/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-portal-compat', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-portal/library/jest.config.js b/packages/react-components/react-portal/library/jest.config.js index 8b3dbc1de02a3..955789b7724bb 100644 --- a/packages/react-components/react-portal/library/jest.config.js +++ b/packages/react-components/react-portal/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-portal', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-positioning/jest.config.js b/packages/react-components/react-positioning/jest.config.js index 79a803b4bf803..6587f904ea9cd 100644 --- a/packages/react-components/react-positioning/jest.config.js +++ b/packages/react-components/react-positioning/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-positioning', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-progress/library/jest.config.js b/packages/react-components/react-progress/library/jest.config.js index c619adbfeeb30..a64b452928202 100644 --- a/packages/react-components/react-progress/library/jest.config.js +++ b/packages/react-components/react-progress/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-progress', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-provider/library/jest.config.js b/packages/react-components/react-provider/library/jest.config.js index c65ef34170d1a..d087946492e97 100644 --- a/packages/react-components/react-provider/library/jest.config.js +++ b/packages/react-components/react-provider/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-provider', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-radio/library/jest.config.js b/packages/react-components/react-radio/library/jest.config.js index 1d0ae84e333f6..83a890baad907 100644 --- a/packages/react-components/react-radio/library/jest.config.js +++ b/packages/react-components/react-radio/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-radio', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-rating/library/jest.config.js b/packages/react-components/react-rating/library/jest.config.js index 203ad5c1bc477..15bd961b60bd0 100644 --- a/packages/react-components/react-rating/library/jest.config.js +++ b/packages/react-components/react-rating/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-rating', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-search/library/jest.config.js b/packages/react-components/react-search/library/jest.config.js index d5b1da4bd5ac6..2a7c6ccd16fbc 100644 --- a/packages/react-components/react-search/library/jest.config.js +++ b/packages/react-components/react-search/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-search', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-select/library/jest.config.js b/packages/react-components/react-select/library/jest.config.js index 3fb60015a2ba7..33e62cbe01e3a 100644 --- a/packages/react-components/react-select/library/jest.config.js +++ b/packages/react-components/react-select/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-select', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-shared-contexts/library/jest.config.js b/packages/react-components/react-shared-contexts/library/jest.config.js index fa0b73c92b639..62d67b6efdbd6 100644 --- a/packages/react-components/react-shared-contexts/library/jest.config.js +++ b/packages/react-components/react-shared-contexts/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-shared-contexts', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-skeleton/library/jest.config.js b/packages/react-components/react-skeleton/library/jest.config.js index 4da31cc1a15f4..a97165fc65d46 100644 --- a/packages/react-components/react-skeleton/library/jest.config.js +++ b/packages/react-components/react-skeleton/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-skeleton', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-slider/library/jest.config.js b/packages/react-components/react-slider/library/jest.config.js index 18370b4ebb07d..c33f57566a1f5 100644 --- a/packages/react-components/react-slider/library/jest.config.js +++ b/packages/react-components/react-slider/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-slider', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-spinbutton/library/jest.config.js b/packages/react-components/react-spinbutton/library/jest.config.js index 9b779cd86a0a2..3e6c92c01b8e6 100644 --- a/packages/react-components/react-spinbutton/library/jest.config.js +++ b/packages/react-components/react-spinbutton/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-spinbutton', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-spinner/library/jest.config.js b/packages/react-components/react-spinner/library/jest.config.js index 5d9cea2fce78e..0f871616c785f 100644 --- a/packages/react-components/react-spinner/library/jest.config.js +++ b/packages/react-components/react-spinner/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-spinner', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-storybook-addon-export-to-sandbox/jest.config.js b/packages/react-components/react-storybook-addon-export-to-sandbox/jest.config.js index e1944016224b5..18cbe0b829962 100644 --- a/packages/react-components/react-storybook-addon-export-to-sandbox/jest.config.js +++ b/packages/react-components/react-storybook-addon-export-to-sandbox/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-storybook-addon-export-to-sandbox', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-storybook-addon-export-to-sandbox/package.json b/packages/react-components/react-storybook-addon-export-to-sandbox/package.json index 38ad8f9048e99..dc9ee40ab48b9 100644 --- a/packages/react-components/react-storybook-addon-export-to-sandbox/package.json +++ b/packages/react-components/react-storybook-addon-export-to-sandbox/package.json @@ -28,10 +28,9 @@ }, "dependencies": { "@swc/helpers": "^0.5.1", - "@types/dedent": "0.7.0", "codesandbox-import-utils": "2.2.3", "@fluentui/babel-preset-storybook-full-source": "^0.0.1", - "dedent": "0.7.0" + "dedent": "^1.2.0" }, "peerDependencies": { "@storybook/addons": "^6.5.15" diff --git a/packages/react-components/react-storybook-addon-export-to-sandbox/src/sandbox-scaffold.ts b/packages/react-components/react-storybook-addon-export-to-sandbox/src/sandbox-scaffold.ts index d07e3b331fed5..6bacb6f126799 100644 --- a/packages/react-components/react-storybook-addon-export-to-sandbox/src/sandbox-scaffold.ts +++ b/packages/react-components/react-storybook-addon-export-to-sandbox/src/sandbox-scaffold.ts @@ -1,4 +1,4 @@ -import * as dedent from 'dedent'; +import dedent from 'dedent'; import type { Data } from './sandbox-utils'; import { serializeJson } from './utils'; diff --git a/packages/react-components/react-storybook-addon-export-to-sandbox/src/sandbox-utils.ts b/packages/react-components/react-storybook-addon-export-to-sandbox/src/sandbox-utils.ts index 72b99b8a6e718..d4a29ad8d748b 100644 --- a/packages/react-components/react-storybook-addon-export-to-sandbox/src/sandbox-utils.ts +++ b/packages/react-components/react-storybook-addon-export-to-sandbox/src/sandbox-utils.ts @@ -1,4 +1,4 @@ -import * as dedent from 'dedent'; +import dedent from 'dedent'; import { getDependencies } from './getDependencies'; import { StoryContext, ParametersExtension } from './types'; diff --git a/packages/react-components/react-storybook-addon/jest.config.js b/packages/react-components/react-storybook-addon/jest.config.js index b964497f55b78..b574ad1c80134 100644 --- a/packages/react-components/react-storybook-addon/jest.config.js +++ b/packages/react-components/react-storybook-addon/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-storybook-addon', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-swatch-picker/library/jest.config.js b/packages/react-components/react-swatch-picker/library/jest.config.js index 310e728311f7b..0e90729c7be2e 100644 --- a/packages/react-components/react-swatch-picker/library/jest.config.js +++ b/packages/react-components/react-swatch-picker/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-swatch-picker', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-switch/library/jest.config.js b/packages/react-components/react-switch/library/jest.config.js index ebc717640b924..22b65fd50ab9a 100644 --- a/packages/react-components/react-switch/library/jest.config.js +++ b/packages/react-components/react-switch/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-switch', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-table/library/jest.config.js b/packages/react-components/react-table/library/jest.config.js index b546f2b9f653d..9af0d4c3f4985 100644 --- a/packages/react-components/react-table/library/jest.config.js +++ b/packages/react-components/react-table/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-table', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-tabs/library/jest.config.js b/packages/react-components/react-tabs/library/jest.config.js index 601db77b5d204..68822c16a55bd 100644 --- a/packages/react-components/react-tabs/library/jest.config.js +++ b/packages/react-components/react-tabs/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-tabs', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-tabster/jest.config.js b/packages/react-components/react-tabster/jest.config.js index 54f16c343f340..153d5076c6235 100644 --- a/packages/react-components/react-tabster/jest.config.js +++ b/packages/react-components/react-tabster/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-tabster', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-tag-picker/library/jest.config.js b/packages/react-components/react-tag-picker/library/jest.config.js index 1d7796997949a..b315ab22e1be2 100644 --- a/packages/react-components/react-tag-picker/library/jest.config.js +++ b/packages/react-components/react-tag-picker/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-tag-picker', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-tags/library/jest.config.js b/packages/react-components/react-tags/library/jest.config.js index 8fe888fa06c9c..48f5a22a59a58 100644 --- a/packages/react-components/react-tags/library/jest.config.js +++ b/packages/react-components/react-tags/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-tags', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-teaching-popover/library/jest.config.js b/packages/react-components/react-teaching-popover/library/jest.config.js index b647c5d819ca3..a08aeefa78112 100644 --- a/packages/react-components/react-teaching-popover/library/jest.config.js +++ b/packages/react-components/react-teaching-popover/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-teaching-popover', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-text/library/jest.config.js b/packages/react-components/react-text/library/jest.config.js index 1005a4d8039fc..695bb6aa25dd9 100644 --- a/packages/react-components/react-text/library/jest.config.js +++ b/packages/react-components/react-text/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-text', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-textarea/library/jest.config.js b/packages/react-components/react-textarea/library/jest.config.js index 81e33ca599bc8..aa8f59406eb48 100644 --- a/packages/react-components/react-textarea/library/jest.config.js +++ b/packages/react-components/react-textarea/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-textarea', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-theme-sass/jest.config.js b/packages/react-components/react-theme-sass/jest.config.js index 65d4ee5012197..3c9bd1fda6289 100644 --- a/packages/react-components/react-theme-sass/jest.config.js +++ b/packages/react-components/react-theme-sass/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -8,13 +27,7 @@ module.exports = { preset: '../../../jest.preset.js', testEnvironment: 'jest-environment-node-single-context', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-theme/library/jest.config.js b/packages/react-components/react-theme/library/jest.config.js index accdedc2c11a9..3dfaedadb6825 100644 --- a/packages/react-components/react-theme/library/jest.config.js +++ b/packages/react-components/react-theme/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-theme', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-timepicker-compat/library/jest.config.js b/packages/react-components/react-timepicker-compat/library/jest.config.js index f4cbab0453b68..f95844785fa1f 100644 --- a/packages/react-components/react-timepicker-compat/library/jest.config.js +++ b/packages/react-components/react-timepicker-compat/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-timepicker-compat', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-toast/library/jest.config.js b/packages/react-components/react-toast/library/jest.config.js index f4102c6d92846..737d10db08c03 100644 --- a/packages/react-components/react-toast/library/jest.config.js +++ b/packages/react-components/react-toast/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-toast', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-toolbar/library/jest.config.js b/packages/react-components/react-toolbar/library/jest.config.js index c48ed55b943fb..6f55a34c260cd 100644 --- a/packages/react-components/react-toolbar/library/jest.config.js +++ b/packages/react-components/react-toolbar/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-toolbar', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-tooltip/library/jest.config.js b/packages/react-components/react-tooltip/library/jest.config.js index 3305d29ea6f7a..2e1fce8af76dd 100644 --- a/packages/react-components/react-tooltip/library/jest.config.js +++ b/packages/react-components/react-tooltip/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-tooltip', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-tree/library/jest.config.js b/packages/react-components/react-tree/library/jest.config.js index ec8a55a573739..6bc2ce169094f 100644 --- a/packages/react-components/react-tree/library/jest.config.js +++ b/packages/react-components/react-tree/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-tree', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-utilities-compat/library/jest.config.js b/packages/react-components/react-utilities-compat/library/jest.config.js index a73f5f722cafa..9158bb9620eb9 100644 --- a/packages/react-components/react-utilities-compat/library/jest.config.js +++ b/packages/react-components/react-utilities-compat/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-utilities-compat', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-utilities/jest.config.js b/packages/react-components/react-utilities/jest.config.js index 468a90a569b59..5ffa53cf8a960 100644 --- a/packages/react-components/react-utilities/jest.config.js +++ b/packages/react-components/react-utilities/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-utilities', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/react-virtualizer/library/jest.config.js b/packages/react-components/react-virtualizer/library/jest.config.js index 274cd54fa603d..dc88c3fa6d9af 100644 --- a/packages/react-components/react-virtualizer/library/jest.config.js +++ b/packages/react-components/react-virtualizer/library/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-virtualizer', preset: '../../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/recipes/jest.config.js b/packages/react-components/recipes/jest.config.js index 3c3a931643c15..fbe85e6c18c36 100644 --- a/packages/react-components/recipes/jest.config.js +++ b/packages/react-components/recipes/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'recipes', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/theme-designer/jest.config.js b/packages/react-components/theme-designer/jest.config.js index 573df14fed481..1a7ac3ce4e64b 100644 --- a/packages/react-components/theme-designer/jest.config.js +++ b/packages/react-components/theme-designer/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'theme-designer', preset: '../../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/react-components/theme-designer/package.json b/packages/react-components/theme-designer/package.json index bac92d2307f91..5c30856823891 100644 --- a/packages/react-components/theme-designer/package.json +++ b/packages/react-components/theme-designer/package.json @@ -40,7 +40,7 @@ "@fluentui/react-utilities": "^9.18.13", "@griffel/react": "^1.5.22", "@swc/helpers": "^0.5.1", - "@types/dedent": "0.7.0", + "dedent": "^1.2.0", "codesandbox-import-utils": "2.2.3" }, "peerDependencies": { diff --git a/packages/react-components/theme-designer/src/components/Export/ExportLink.tsx b/packages/react-components/theme-designer/src/components/Export/ExportLink.tsx index 202d3b33169df..ea06cc079b7bd 100644 --- a/packages/react-components/theme-designer/src/components/Export/ExportLink.tsx +++ b/packages/react-components/theme-designer/src/components/Export/ExportLink.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { Link } from '@fluentui/react-components'; import { getParameters } from 'codesandbox-import-utils/lib/api/define'; -import * as dedent from 'dedent'; +import dedent from 'dedent'; import { getBrandValues, objectToString } from '../../utils/toString'; import { useThemeDesigner } from '../../Context/ThemeDesignerContext'; const defaultFileToPreview = encodeURIComponent('/index.tsx'); @@ -41,8 +41,8 @@ export const ExportLink = () => { TabList, Title3, useId, - Dropdown, - Option + Dropdown, + Option } from "@fluentui/react-components"; import type { Theme } from "@fluentui/react-components"; import { diff --git a/packages/react-components/theme-designer/src/components/Export/ExportPanel.tsx b/packages/react-components/theme-designer/src/components/Export/ExportPanel.tsx index ab268982da65c..4cf65bc0bdc2d 100644 --- a/packages/react-components/theme-designer/src/components/Export/ExportPanel.tsx +++ b/packages/react-components/theme-designer/src/components/Export/ExportPanel.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import * as dedent from 'dedent'; +import dedent from 'dedent'; import { makeStyles } from '@griffel/react'; import { Body1, @@ -74,7 +74,7 @@ export const ExportPanel = () => { const darkTheme: Theme = { ...createDarkTheme(${themeName}), ${getBrandValues(brand, darkThemeOverrides, themeName, '\u00A0\u00A0')} }; - + darkTheme.colorBrandForeground1 = ${themeName}[110]; darkTheme.colorBrandForeground2 = ${themeName}[120]; @@ -92,7 +92,7 @@ export const ExportPanel = () => { }, null, '\t', - )} + )} `; const exportedValue = React.useMemo(() => { diff --git a/packages/react-conformance/jest.config.js b/packages/react-conformance/jest.config.js index 735d4719423a2..bf4405ad8bc0c 100644 --- a/packages/react-conformance/jest.config.js +++ b/packages/react-conformance/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'react-conformance', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/packages/tokens/jest.config.js b/packages/tokens/jest.config.js index b514a536ab0f3..de65df8acd43f 100644 --- a/packages/tokens/jest.config.js +++ b/packages/tokens/jest.config.js @@ -1,4 +1,23 @@ // @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; /** * @type {import('@jest/types').Config.InitialOptions} @@ -7,13 +26,7 @@ module.exports = { displayName: 'tokens', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], }, coverageDirectory: './coverage', setupFilesAfterEnv: ['./config/tests.js'], diff --git a/scripts/api-extractor/jest.config.js b/scripts/api-extractor/jest.config.js index 4d2bd54fb3634..11e37e6596e4d 100644 --- a/scripts/api-extractor/jest.config.js +++ b/scripts/api-extractor/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-api-extractor', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/babel/jest.config.js b/scripts/babel/jest.config.js index c102b7d7ada04..9a99d61173a23 100644 --- a/scripts/babel/jest.config.js +++ b/scripts/babel/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-babel', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/beachball/jest.config.js b/scripts/beachball/jest.config.js index bc54d3f613902..731f8d77be7c7 100644 --- a/scripts/beachball/jest.config.js +++ b/scripts/beachball/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-beachball', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/cypress/jest.config.js b/scripts/cypress/jest.config.js index cf8c2d9368bd9..e0744b3f5f4e7 100644 --- a/scripts/cypress/jest.config.js +++ b/scripts/cypress/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-cypress', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/dangerjs/jest.config.js b/scripts/dangerjs/jest.config.js index a8161cfa8a28c..60caa2a91cbb2 100644 --- a/scripts/dangerjs/jest.config.js +++ b/scripts/dangerjs/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-dangerjs', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/executors/jest.config.js b/scripts/executors/jest.config.js index ea47b9186999a..69b145efcfc1e 100644 --- a/scripts/executors/jest.config.js +++ b/scripts/executors/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-executors', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/fluentui-publish/jest.config.js b/scripts/fluentui-publish/jest.config.js index 776ffa42f71e8..7d730973be433 100644 --- a/scripts/fluentui-publish/jest.config.js +++ b/scripts/fluentui-publish/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-fluentui-publish', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/generators/jest.config.js b/scripts/generators/jest.config.js index 4411b965024e7..0111e9d3d3205 100644 --- a/scripts/generators/jest.config.js +++ b/scripts/generators/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-generators', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/github/jest.config.js b/scripts/github/jest.config.js index c3c326cb4025a..d58eb05283293 100644 --- a/scripts/github/jest.config.js +++ b/scripts/github/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-github', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/gulp/jest.config.js b/scripts/gulp/jest.config.js index 589d5aee8ad29..9d5bbdb7def88 100644 --- a/scripts/gulp/jest.config.js +++ b/scripts/gulp/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-gulp', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/jest/jest.config.js b/scripts/jest/jest.config.js index e1969b2d4a8d7..a275fcc5eccd4 100644 --- a/scripts/jest/jest.config.js +++ b/scripts/jest/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-jest', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/lint-staged/jest.config.js b/scripts/lint-staged/jest.config.js index e938393c610d8..8e3e5a81a487d 100644 --- a/scripts/lint-staged/jest.config.js +++ b/scripts/lint-staged/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-lint-staged', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/monorepo/jest.config.js b/scripts/monorepo/jest.config.js index 76c467f23c9a5..e2f16438c9606 100644 --- a/scripts/monorepo/jest.config.js +++ b/scripts/monorepo/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-monorepo', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/package-manager/jest.config.js b/scripts/package-manager/jest.config.js index 36ba4df1a82a6..15b2161da6473 100644 --- a/scripts/package-manager/jest.config.js +++ b/scripts/package-manager/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-package-manager', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/perf-test-flamegrill/jest.config.js b/scripts/perf-test-flamegrill/jest.config.js index 954193d0667f8..9f2a556183bcc 100644 --- a/scripts/perf-test-flamegrill/jest.config.js +++ b/scripts/perf-test-flamegrill/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-perf-test-flamegrill', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/prettier/jest.config.js b/scripts/prettier/jest.config.js index ce83af4e5369d..885609aaf4b9d 100644 --- a/scripts/prettier/jest.config.js +++ b/scripts/prettier/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-prettier', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/projects-test/jest.config.js b/scripts/projects-test/jest.config.js index 0fbd29c67d609..5185d72eb4453 100644 --- a/scripts/projects-test/jest.config.js +++ b/scripts/projects-test/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-projects-test', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/puppeteer/jest.config.js b/scripts/puppeteer/jest.config.js index 8704a5fb078e7..fddb0954d1fd5 100644 --- a/scripts/puppeteer/jest.config.js +++ b/scripts/puppeteer/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-puppeteer', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, moduleNameMapper: { '^puppeteer-core/internal/(.*)': '/../../node_modules/puppeteer-core/lib/cjs/puppeteer/$1', diff --git a/scripts/storybook/jest.config.js b/scripts/storybook/jest.config.js index a2868d86e59ac..7432530fbf77d 100644 --- a/scripts/storybook/jest.config.js +++ b/scripts/storybook/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-storybook', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/tasks/jest.config.js b/scripts/tasks/jest.config.js index e31c2bd02057b..62b0fbe16ba68 100644 --- a/scripts/tasks/jest.config.js +++ b/scripts/tasks/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-tasks', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/test-ssr/jest.config.js b/scripts/test-ssr/jest.config.js index 80e8ff1afc308..7ab9d43b90e33 100644 --- a/scripts/test-ssr/jest.config.js +++ b/scripts/test-ssr/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-test-ssr', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/triage-bot/jest.config.js b/scripts/triage-bot/jest.config.js index e77a86ad9d420..9ad9e805a7a4f 100644 --- a/scripts/triage-bot/jest.config.js +++ b/scripts/triage-bot/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-triage-bot', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/ts-node/jest.config.js b/scripts/ts-node/jest.config.js index 2766a396cbc9d..16b11621bf275 100644 --- a/scripts/ts-node/jest.config.js +++ b/scripts/ts-node/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-ts-node', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/update-release-notes/jest.config.js b/scripts/update-release-notes/jest.config.js index 3dd75a9b454bb..05bdf89d6cea9 100644 --- a/scripts/update-release-notes/jest.config.js +++ b/scripts/update-release-notes/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-update-release-notes', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/utils/jest.config.js b/scripts/utils/jest.config.js index cb4d7d31db522..ef0bc81c23c85 100644 --- a/scripts/utils/jest.config.js +++ b/scripts/utils/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-utils', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/scripts/webpack/jest.config.js b/scripts/webpack/jest.config.js index 1e04af9fe3148..5fe0aaaabcbfc 100644 --- a/scripts/webpack/jest.config.js +++ b/scripts/webpack/jest.config.js @@ -7,13 +7,7 @@ module.exports = { displayName: 'scripts-webpack', preset: '../../jest.preset.js', transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - isolatedModules: true, - }, - ], + '^.+\\.tsx?$': ['@swc/jest', {}], }, coverageDirectory: './coverage', testEnvironment: 'node', diff --git a/syncpack.config.js b/syncpack.config.js index 60d8a13f0cb93..5be04a7ee044a 100644 --- a/syncpack.config.js +++ b/syncpack.config.js @@ -69,6 +69,7 @@ const config = { 'webpack', 'webpack-bundle-analyzer', 'yargs', + 'dedent', ], }, { diff --git a/tools/eslint-rules/jest.config.ts b/tools/eslint-rules/jest.config.ts index 360578d5d5ed0..7b931b87d5b9a 100644 --- a/tools/eslint-rules/jest.config.ts +++ b/tools/eslint-rules/jest.config.ts @@ -3,14 +3,7 @@ export default { displayName: 'eslint-rules', preset: '../../jest.preset.js', transform: { - '^.+\\.[tj]s$': [ - 'ts-jest', - { - diagnostics: false, - isolatedModules: true, - tsconfig: '/tsconfig.spec.json', - }, - ], + '^.+\\.[tj]s$': ['@swc/jest', {}], }, moduleFileExtensions: ['ts', 'js', 'html'], coverageDirectory: '../../coverage/tools/eslint-rules', diff --git a/tools/workspace-plugin/jest.config.ts b/tools/workspace-plugin/jest.config.ts index cc41d6f58b725..f57d5de6bf3e4 100644 --- a/tools/workspace-plugin/jest.config.ts +++ b/tools/workspace-plugin/jest.config.ts @@ -4,14 +4,7 @@ export default { displayName: 'workspace-plugin', preset: '../../jest.preset.js', transform: { - '^.+\\.[tj]s$': [ - 'ts-jest', - { - diagnostics: false, - isolatedModules: true, - tsconfig: '/tsconfig.spec.json', - }, - ], + '^.+\\.[tj]s$': ['@swc/jest', {}], }, moduleFileExtensions: ['ts', 'js', 'html'], coverageDirectory: '../../coverage/tools/workspace-plugin', diff --git a/tools/workspace-plugin/src/generators/migrate-converged-pkg/index.spec.ts b/tools/workspace-plugin/src/generators/migrate-converged-pkg/index.spec.ts index e81c228d66716..257a43a7cb1cb 100644 --- a/tools/workspace-plugin/src/generators/migrate-converged-pkg/index.spec.ts +++ b/tools/workspace-plugin/src/generators/migrate-converged-pkg/index.spec.ts @@ -37,10 +37,10 @@ jest.mock( 'enquirer', () => ({ - prompt: async () => ({ + prompt: jest.fn(async () => ({ name: '', - }), - } as Pick), + })), + } satisfies Pick), ); describe('migrate-converged-pkg generator', () => { diff --git a/yarn.lock b/yarn.lock index 7c74128db8426..3c7d20c925338 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2295,6 +2295,13 @@ slash "^3.0.0" strip-ansi "^6.0.0" +"@jest/create-cache-key-function@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/create-cache-key-function/-/create-cache-key-function-29.7.0.tgz#793be38148fab78e65f40ae30c36785f4ad859f0" + integrity sha512-4QqS3LY5PBmTRHj9sAg1HLoPzqAI0uOX6wI/TRqHIcOxlFidy6YEmCQJk6FSZjNLGCeubDMfmkWL+qaLKhSGQA== + dependencies: + "@jest/types" "^29.6.3" + "@jest/environment@^29.7.0": version "29.7.0" resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-29.7.0.tgz#24d61f54ff1f786f3cd4073b4b94416383baf2a7" @@ -4710,6 +4717,15 @@ dependencies: tslib "^2.4.0" +"@swc/jest@0.2.36": + version "0.2.36" + resolved "https://registry.yarnpkg.com/@swc/jest/-/jest-0.2.36.tgz#2797450a30d28b471997a17e901ccad946fe693e" + integrity sha512-8X80dp81ugxs4a11z1ka43FPhP+/e+mJNXJSxiNYk8gIX/jPBtY4gQTrKu/KIoco8bzKuPI5lUxjfLiGsfvnlw== + dependencies: + "@jest/create-cache-key-function" "^29.7.0" + "@swc/counter" "^0.1.3" + jsonc-parser "^3.2.0" + "@swc/types@0.1.7": version "0.1.7" resolved "https://registry.yarnpkg.com/@swc/types/-/types-0.1.7.tgz#ea5d658cf460abff51507ca8d26e2d391bafb15e" @@ -5200,11 +5216,6 @@ resolved "https://registry.yarnpkg.com/@types/d3-time/-/d3-time-2.1.4.tgz#43587aa57d565ab60a1d2201edeebc497d5c1252" integrity sha512-BTfLsxTeo7yFxI/haOOf1ZwJ6xKgQLT9dCp+EcmQv87Gox6X+oKl4mLKfO6fnWm3P22+A6DknMNEZany8ql2Rw== -"@types/dedent@0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@types/dedent/-/dedent-0.7.0.tgz#155f339ca404e6dd90b9ce46a3f78fd69ca9b050" - integrity sha512-EGlKlgMhnLt/cM4DbUSafFdrkeJoC9Mvnj0PUCU7tFmTjMjNRT957kXCx0wYm3JuEq4o4ZsS5vG+NlkM2DMd2A== - "@types/deep-assign@^0.1.1": version "0.1.1" resolved "https://registry.yarnpkg.com/@types/deep-assign/-/deep-assign-0.1.1.tgz#c10aa2d6202774015f5820ed303b82ab3b0bde9b" @@ -10438,16 +10449,16 @@ decompress-response@^6.0.0: dependencies: mimic-response "^3.1.0" -dedent@0.7.0, dedent@^0.7.0: +dedent@1.2.0, dedent@^1.0.0, dedent@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.2.0.tgz#32039cd75c035f684e01c4a07cb88c0ecbeb57be" + integrity sha512-i4tcg0ClgvMUSxwHpt+NHQ01ZJmAkl6eBvDNrSZG9e+oLRTCSHv0wpr/Bzjpf6CwKeIHGevE1M34Y1Axdms5VQ== + +dedent@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" integrity sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw= -dedent@^1.0.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.5.1.tgz#4f3fc94c8b711e9bb2800d185cd6ad20f2a90aff" - integrity sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg== - deep-assign@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/deep-assign/-/deep-assign-2.0.0.tgz#ebe06b1f07f08dae597620e3dd1622f371a1c572" @@ -16373,7 +16384,7 @@ jsonc-eslint-parser@2.3.0, jsonc-eslint-parser@^2.1.0: espree "^9.0.0" semver "^7.3.5" -jsonc-parser@3.2.0: +jsonc-parser@3.2.0, jsonc-parser@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz#31ff3f4c2b9793f89c67212627c51c6394f88e76" integrity sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==