Skip to content

Commit

Permalink
feat(typescript): add @swc/jest and use it instead of babel
Browse files Browse the repository at this point in the history
  • Loading branch information
maximedasilva committed Feb 29, 2024
1 parent 680d5a0 commit 5a9338c
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@storybook/react": "7.5.1",
"@storybook/react-webpack5": "7.5.1",
"@swc/core": "1.4.2",
"@swc/jest": "0.2.36",
"@testing-library/jest-dom": "6.1.4",
"@testing-library/react": "14.0.0",
"@testing-library/user-event": "14.5.1",
Expand Down
14 changes: 14 additions & 0 deletions packages/core/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ module.exports = {
fakeTimers: {
enableGlobally: false,
},
transform: {
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
jsc: {
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
},
testMatch: ['<rootDir>/packages/core/lib/**/*.test.ts'],
testPathIgnorePatterns: [
'/node_modules/',
Expand Down
14 changes: 14 additions & 0 deletions packages/hooks/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ module.exports = {
fakeTimers: {
enableGlobally: false,
},
transform: {
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
jsc: {
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
},
moduleNameMapper: {
'^@junipero/(.+)$': '<rootDir>/packages/$1/lib/index.js',
'^~tests?-utils$': '<rootDir>/packages/react/tests/utils.ts',
Expand Down
14 changes: 14 additions & 0 deletions packages/react-d3-plugin/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ module.exports = {
fakeTimers: {
enableGlobally: false,
},
transform: {
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
jsc: {
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
},
moduleNameMapper: {
'^@junipero/transitions': '<rootDir>/packages/transitions/lib/index.tsx',
'^@junipero/(.+)$': '<rootDir>/packages/$1/lib/index.ts',
Expand Down
14 changes: 14 additions & 0 deletions packages/react/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ module.exports = {
fakeTimers: {
enableGlobally: false,
},
transform: {
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
jsc: {
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
},
moduleNameMapper: {
'^@junipero/transitions': '<rootDir>/packages/transitions/lib/index.tsx',
'^@junipero/(.+)$': '<rootDir>/packages/$1/lib/index.ts',
Expand Down
14 changes: 14 additions & 0 deletions packages/tailwind-plugin/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ module.exports = {
fakeTimers: {
enableGlobally: false,
},
transform: {
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
jsc: {
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
},
moduleNameMapper: {
'^@junipero/transitions': '<rootDir>/packages/transitions/lib/index.tsx',
'^@junipero/(.+)$': '<rootDir>/packages/$1/lib/index.ts',
Expand Down
14 changes: 14 additions & 0 deletions packages/transitions/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ module.exports = {
fakeTimers: {
enableGlobally: false,
},
transform: {
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
jsc: {
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
},
moduleNameMapper: {
'^@junipero/transitions': '<rootDir>/packages/transitions/lib/index.tsx',
'^@junipero/(.+)$': '<rootDir>/packages/$1/lib/index.ts',
Expand Down
30 changes: 30 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,15 @@ __metadata:
languageName: node
linkType: hard

"@jest/create-cache-key-function@npm:^29.7.0":
version: 29.7.0
resolution: "@jest/create-cache-key-function@npm:29.7.0"
dependencies:
"@jest/types": "npm:^29.6.3"
checksum: 10c0/5c47ef62205264adf77b1ff26b969ce9fe84920b8275c3c5e83f4236859d6ae5e4e7027af99eef04a8e334c4e424d44af3e167972083406070aca733ac2a2795
languageName: node
linkType: hard

"@jest/environment@npm:^29.7.0":
version: 29.7.0
resolution: "@jest/environment@npm:29.7.0"
Expand Down Expand Up @@ -4813,6 +4822,19 @@ __metadata:
languageName: node
linkType: hard

"@swc/jest@npm:0.2.36":
version: 0.2.36
resolution: "@swc/jest@npm:0.2.36"
dependencies:
"@jest/create-cache-key-function": "npm:^29.7.0"
"@swc/counter": "npm:^0.1.3"
jsonc-parser: "npm:^3.2.0"
peerDependencies:
"@swc/core": "*"
checksum: 10c0/7f1993f9201420bb499c92ab28797352bcbf9e3a6c7b5a1806fdc34c9c3b46ea9e5b2f070c0e13fcf7f3c3fadbbc38777840baabb178f589bf1f67543763adb6
languageName: node
linkType: hard

"@swc/types@npm:^0.1.5":
version: 0.1.5
resolution: "@swc/types@npm:0.1.5"
Expand Down Expand Up @@ -12410,6 +12432,13 @@ __metadata:
languageName: node
linkType: hard

"jsonc-parser@npm:^3.2.0":
version: 3.2.1
resolution: "jsonc-parser@npm:3.2.1"
checksum: 10c0/ada66dec143d7f9cb0e2d0d29c69e9ce40d20f3a4cb96b0c6efb745025ac7f9ba647d7ac0990d0adfc37a2d2ae084a12009a9c833dbdbeadf648879a99b9df89
languageName: node
linkType: hard

"jsonfile@npm:^6.0.1":
version: 6.1.0
resolution: "jsonfile@npm:6.1.0"
Expand Down Expand Up @@ -15842,6 +15871,7 @@ __metadata:
"@storybook/react": "npm:7.5.1"
"@storybook/react-webpack5": "npm:7.5.1"
"@swc/core": "npm:1.4.2"
"@swc/jest": "npm:0.2.36"
"@testing-library/jest-dom": "npm:6.1.4"
"@testing-library/react": "npm:14.0.0"
"@testing-library/user-event": "npm:14.5.1"
Expand Down

0 comments on commit 5a9338c

Please sign in to comment.