Skip to content

Commit

Permalink
chore: change babel-transform to swc for jest
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector authored and BroKun committed Nov 21, 2023
1 parent 1965733 commit 1dcfd6f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 19 additions & 2 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,31 @@ const __dirname = path.dirname(__filename);

import { defaults } from 'jest-config';

const swcJestConfig = {
sourceMaps: false,
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
decorators: true,
},

transform: {
react: {
runtime: 'automatic',
},
},
},
};

const configs = {
moduleFileExtensions: [...defaults.moduleFileExtensions, 'js', 'ts', 'tsx'],
verbose: true,
testRegex: '(/__test__/.*|(\\.|/)(test|spec))\\.tsx?$',
resolver: `${__dirname}/scripts/jest-resolver.cjs`,
transform: {
'^.+\\.(ts|tsx)?$': 'babel-jest',
'^.+\\.(js|jsx)$': 'babel-jest',
'^.+\\.(ts|tsx)?$': ['@swc/jest', swcJestConfig],
'^.+\\.(js|jsx)$': ['@swc/jest', swcJestConfig],
},
transformIgnorePatterns: [
'^/node_modules/(?!react-dnd|dnd-core|query-string|@react-dnd)',
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
"prettier": "^3.0.3",
"react-test-renderer": "^18.2.0",
"stylelint": "^14.16.1",
"typescript": "^4.9.5"
"typescript": "^4.9.5",
"@swc/core": "^1.3.99",
"@swc/jest": "^0.2.29"
},
"engines": {
"node": ">=16.20.0"
Expand Down

0 comments on commit 1dcfd6f

Please sign in to comment.