Skip to content

Commit

Permalink
chore: migrate v9 and tools projects to @swc/jest (#32106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hotell authored Jul 26, 2024
1 parent 8b0602e commit 35b98cf
Show file tree
Hide file tree
Showing 131 changed files with 1,822 additions and 862 deletions.
8 changes: 1 addition & 7 deletions apps/react-18-tests-v9/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ module.exports = {
'^react-dom$': '<rootDir>/node_modules/react-dom',
},
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true,
},
],
'^.+\\.tsx?$': ['@swc/jest', {}],
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
Expand Down
8 changes: 1 addition & 7 deletions apps/ssr-tests-v9/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ module.exports = {
displayName: 'ssr-tests-v9',
preset: '../../jest.preset.js',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true,
},
],
'^.+\\.tsx?$': ['@swc/jest', {}],
},
testEnvironment: 'node',
coverageDirectory: './coverage',
Expand Down
3 changes: 2 additions & 1 deletion apps/theming-designer/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"name": "theming-designer",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"implicitDependencies": []
"implicitDependencies": [],
"tags": ["v8"]
}
8 changes: 1 addition & 7 deletions apps/vr-tests-react-components/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ module.exports = {
displayName: 'vr-tests-react-components',
preset: '../../jest.preset.js',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.json',
isolatedModules: true,
},
],
'^.+\\.tsx?$': ['@swc/jest', {}],
},
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -213,7 +213,7 @@
"cypress-real-events": "1.11.0",
"cypress-storybook": "0.5.1",
"danger": "^11.0.0",
"dedent": "0.7.0",
"dedent": "1.2.0",
"del": "6.0.0",
"doctoc": "2.0.1",
"doctrine": "3.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -7,13 +26,7 @@ module.exports = {
displayName: 'babel-preset-global-context',
preset: '../../../jest.preset.js',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true,
},
],
'^.+\\.tsx?$': ['@swc/jest', swcJestConfig],
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
Expand Down
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -7,13 +26,7 @@ module.exports = {
displayName: 'babel-preset-storybook-full-source',
preset: '../../../jest.preset.js',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true,
},
],
'^.+\\.tsx?$': ['@swc/jest', swcJestConfig],
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
Expand Down
27 changes: 20 additions & 7 deletions packages/react-components/global-context/jest.config.js
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -7,13 +26,7 @@ module.exports = {
displayName: 'global-context',
preset: '../../../jest.preset.js',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true,
},
],
'^.+\\.tsx?$': ['@swc/jest', swcJestConfig],
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
Expand Down
27 changes: 20 additions & 7 deletions packages/react-components/keyboard-keys/jest.config.js
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -7,13 +26,7 @@ module.exports = {
displayName: 'keyboard-keys',
preset: '../../../jest.preset.js',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true,
},
],
'^.+\\.tsx?$': ['@swc/jest', swcJestConfig],
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
Expand Down
27 changes: 20 additions & 7 deletions packages/react-components/priority-overflow/jest.config.js
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -7,13 +26,7 @@ module.exports = {
displayName: 'priority-overflow',
preset: '../../../jest.preset.js',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true,
},
],
'^.+\\.tsx?$': ['@swc/jest', swcJestConfig],
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
Expand Down
27 changes: 20 additions & 7 deletions packages/react-components/react-accordion/library/jest.config.js
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -7,13 +26,7 @@ module.exports = {
displayName: 'react-accordion',
preset: '../../../../jest.preset.js',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true,
},
],
'^.+\\.tsx?$': ['@swc/jest', swcJestConfig],
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
Expand Down
27 changes: 20 additions & 7 deletions packages/react-components/react-aria/library/jest.config.js
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -7,13 +26,7 @@ module.exports = {
displayName: 'react-aria',
preset: '../../../../jest.preset.js',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true,
},
],
'^.+\\.tsx?$': ['@swc/jest', swcJestConfig],
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
Expand Down
27 changes: 20 additions & 7 deletions packages/react-components/react-avatar/library/jest.config.js
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -7,13 +26,7 @@ module.exports = {
displayName: 'react-avatar',
preset: '../../../../jest.preset.js',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true,
},
],
'^.+\\.tsx?$': ['@swc/jest', swcJestConfig],
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
Expand Down
Loading

0 comments on commit 35b98cf

Please sign in to comment.