diff --git a/apps/react-18-tests-v9/jest.config.js b/apps/react-18-tests-v9/jest.config.js index 1f8b56ac7f0fe2..589684f5c50f60 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 c7b8c1451c4d8d..615664666b55b4 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 4ab7f1e294ae5c..876c7d22633b2f 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 58bd73a8c051cc..d6d71f1d5c6770 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 b63ddcfbd2073f..cdf9d3c3f5fce9 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", @@ -212,7 +212,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 82cd532a468416..af23755d8bc08f 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 b2c8dca1b0a8db..123d646708d723 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 edabe8d65358b5..d8b4384a280e01 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 0e329695514a09..757f1c501d40c1 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 4e29b28bbb663f..3885e65adcbb46 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 270c7f58c7e1a2..709e4a2a4da592 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 0ebdbf86df6208..57deee862a091a 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 de3440173a4580..dc18a8504c421d 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 802a89d2a381e8..9774395ae9a231 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 ced5fbbf09179c..3e1bdbdcd121b4 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 12f9f17c8c48f6..6d295e622d5f86 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 e86a78d994b079..f6ebe01a386f10 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 4f2b6b7da79662..818a6fd0a53f6c 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 93fdf7d49c0c1d..98e0e6204880b5 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 3e86e68073187f..605fd226a02e1b 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 ff883d8163c69d..99ac23722e12f8 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 3ff3797baa2a25..28c4aba097cc50 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 db62c9c9ca175e..76e2e0cbe6b4fd 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 99bdc57c3d6344..c37f332f562def 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 5379cd13aea970..094414a8839794 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 151aee01caed7c..b6903810fa45db 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 5e5bcd3073aa9b..61d20ddfe16b41 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 b772f03680d3e0..f78b4bb2bdb9c7 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 86a9742529735e..9bb2d9dde732d7 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 19aa05639c3415..e54733aa0d7ce0 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 76a2433e00b6ea..30599cabbbac9c 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 c82d11aff4fa02..40140f5bad8a89 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 a045910fd15fcb..a2f259c7b7791b 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 bd72d12ff0ceda..1228d0798c7e23 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 a994f2b5cc2359..c871bda7ac9f7c 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 bf5483782926f7..699e1f6ec8e8db 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 e5cca691680a93..f5ec29eee00d72 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 8717bca1e1192e..e3df3d434bcfeb 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 b52897645999d7..53f7c7b70ea8b7 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 de35b54e2c5e5c..fba3cb18a026f8 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 a4a49feec6f173..f6333c979a2ced 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 1d424c1a2b85f3..9bc6e63b6603ef 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 798b5570b4aedf..2669112fea23b8 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 9425868ae0b1d1..b3eb7b68d9f599 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 167a0cab656303..60d0d13c1f7f54 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 b06f29e80fdc56..4b0d5f8d848f16 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 bd26963f1c5ddf..dc5087f49bf2ba 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 0bbbcd9f388692..642673015c1f16 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 1741f7a7749aa9..5a71c159afce69 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 e9b944b5c8b7bc..5c58c51d216190 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 9033b4669fafc5..2993091e84b413 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 02978ea91303db..bad8ac27c7cbe4 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 99cb33b4422414..ae5ce8aeee59a9 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 e24f0b8bfbfc5d..51ee0af9b27e68 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 307eb9b8024cdc..c609a27cf8344a 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 8b3dbc1de02a37..955789b7724bb0 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 79a803b4bf803a..6587f904ea9cd4 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 c619adbfeeb307..a64b452928202e 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 c65ef34170d1ac..d087946492e97d 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 1d0ae84e333f6c..83a890baad907e 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 203ad5c1bc4776..15bd961b60bd06 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 d5b1da4bd5ac65..2a7c6ccd16fbca 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 3fb60015a2ba70..33e62cbe01e3a2 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 fa0b73c92b6390..62d67b6efdbd6d 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 4da31cc1a15f4a..a97165fc65d46d 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 18370b4ebb07d6..c33f57566a1f50 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 9b779cd86a0a25..3e6c92c01b8e6d 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 5d9cea2fce78ec..0f871616c785f6 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 e1944016224b5b..18cbe0b8299628 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 38ad8f9048e993..dc9ee40ab48b99 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 d07e3b331fed55..6bacb6f1267990 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 72b99b8a6e7187..d4a29ad8d748b4 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 b964497f55b785..b574ad1c801349 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 310e728311f7bc..0e90729c7be2e4 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 ebc717640b9241..22b65fd50ab9a6 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 b546f2b9f653da..9af0d4c3f49857 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 601db77b5d204e..68822c16a55bd8 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 54f16c343f3402..153d5076c62352 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 1d7796997949a0..b315ab22e1be2a 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 8fe888fa06c9ca..48f5a22a59a58d 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 b647c5d819ca3d..a08aeefa78112a 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 1005a4d8039fc3..695bb6aa25dd9d 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 81e33ca599bc8d..aa8f59406eb48e 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 65d4ee50121975..3c9bd1fda62897 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 accdedc2c11a9a..3dfaedadb6825c 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 f4cbab0453b68f..f95844785fa1fa 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 f4102c6d928464..737d10db08c03f 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 c48ed55b943fb6..6f55a34c260cdc 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 3305d29ea6f7a2..2e1fce8af76ddf 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 ec8a55a573739e..6bc2ce169094f4 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 a73f5f722cafad..9158bb9620eb9a 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 468a90a569b599..5ffa53cf8a960d 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 274cd54fa603d2..dc88c3fa6d9af5 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 3c3a931643c150..fbe85e6c18c366 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 573df14fed4815..1a7ac3ce4e64ba 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 bac92d2307f912..5c30856823891c 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 202d3b33169dfa..ea06cc079b7bd9 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 ab268982da65cd..4cf65bc0bdc2dc 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 735d4719423a2a..bf4405ad8bc0ca 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 b514a536ab0f3e..de65df8acd43f2 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 4d2bd54fb3634d..11e37e6596e4d1 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 c102b7d7ada045..9a99d61173a230 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 bc54d3f6139021..731f8d77be7c73 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 cf8c2d9368bd93..e0744b3f5f4e7c 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 a8161cfa8a28c4..60caa2a91cbb21 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 ea47b9186999a7..69b145efcfc1ea 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 776ffa42f71e8f..7d730973be4330 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 4411b965024e7d..0111e9d3d32056 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 c3c326cb4025aa..d58eb052832930 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 589d5aee8ad294..9d5bbdb7def880 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 e1969b2d4a8d77..a275fcc5eccd40 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 e938393c610d8d..8e3e5a81a487d6 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 76c467f23c9a54..e2f16438c96068 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 36ba4df1a82a6e..15b2161da64735 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 954193d0667f8d..9f2a556183bccf 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 ce83af4e5369da..885609aaf4b9d1 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 0fbd29c67d609c..5185d72eb4453e 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 8704a5fb078e71..fddb0954d1fd50 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 a2868d86e59ac0..7432530fbf77d1 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 e31c2bd02057bf..62b0fbe16ba68c 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 80e8ff1afc308d..7ab9d43b90e334 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 e77a86ad9d4200..9ad9e805a7a4ff 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 2766a396cbc9de..16b11621bf275c 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 3dd75a9b454bbf..05bdf89d6cea9e 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 cb4d7d31db522b..ef0bc81c23c856 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 1e04af9fe31483..5fe0aaaabcbfc6 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 60d8a13f0cb938..5be04a7ee044af 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 360578d5d5ed06..7b931b87d5b9a4 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 cc41d6f58b7259..f57d5de6bf3e4c 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 e81c228d667169..257a43a7cb1cbe 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 9cdd50ca071f5b..510356ba9cc402 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2292,6 +2292,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" @@ -4696,6 +4703,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" @@ -5186,11 +5202,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" @@ -10385,16 +10396,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" @@ -16208,7 +16219,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==