Skip to content

Commit 78c4d33

Browse files
committed
chore: add jest transformer test
1 parent bb57525 commit 78c4d33

File tree

8 files changed

+1271
-559
lines changed

8 files changed

+1271
-559
lines changed

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ jobs:
6565
- name: Test rollup plugin
6666
run: pnpm rollup-plugin
6767

68+
- name: Test jest transformer
69+
run: pnpm jest-transformer
70+
6871
# - name: Run Unit Test Against Package
6972
# # pnpm has a bug with pack script https://github.com/pnpm/pnpm/issues/4351
7073
# run: |

.remarkignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.stryker-tmp

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default [
66
...tpConfig.configs.base,
77
{
88
files: ['**/*.test.{js,ts}'],
9+
ignores: ['fixtures/**/*'],
910
plugins: { vitest },
1011
rules: {
1112
...vitest.configs.all.rules,

fixtures/webpack.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { describe, expect, it } from '@jest/globals'
2+
3+
import { key } from './webpack.mjs'
4+
5+
describe('jest-plugin', () => {
6+
it('return key', () => {
7+
expect(key.b).toBe('data:a.b')
8+
})
9+
})

jest.config.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** @type {import('jest').Config} */
2+
export default {
3+
roots: ['<rootDir>/fixtures/'],
4+
testMatch: ['**/?(*.)+(test).?([mc])[jt]s?(x)'],
5+
moduleFileExtensions: ['js'],
6+
transform: {
7+
'^.+\\.m?(t|j)sx?$': '@swc/jest',
8+
'data\\.json$': ['json-map-keys-jest', { prefix: '[name]:' }],
9+
},
10+
}

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
"test": "vitest",
2323
"test:mutation": "stryker run",
2424
"webpack-loader": "webpack",
25-
"rollup-plugin": "rollup --config"
25+
"rollup-plugin": "rollup --config",
26+
"jest-transformer": "jest"
2627
},
2728
"dependencies": {
2829
"json-map-keys": "workspace:*",
30+
"json-map-keys-jest": "workspace:*",
2931
"json-map-keys-loader": "workspace:*",
3032
"rollup-plugin-json-map-keys": "workspace:*"
3133
},
@@ -35,6 +37,7 @@
3537
"@stryker-mutator/core": "^9.1.1",
3638
"@stryker-mutator/typescript-checker": "^9.1.1",
3739
"@stryker-mutator/vitest-runner": "^9.1.1",
40+
"@swc/jest": "^0.2.39",
3841
"@tiagoporto/dependabot-config": "^2.4.0",
3942
"@tiagoporto/editor-config": "^2.0.0",
4043
"@tiagoporto/eslint-config": "^5.3.0",
@@ -44,6 +47,7 @@
4447
"@vitest/eslint-plugin": "^1.3.10",
4548
"eslint": "^9.36.0",
4649
"husky": "^9.1.7",
50+
"jest": "^27.0.0",
4751
"lint-staged": "^16.1.6",
4852
"prettier": "^3.6.2",
4953
"remark": "^15.0.1",

pnpm-lock.yaml

Lines changed: 1235 additions & 558 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vitest.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vitest/config'
2+
3+
export default defineConfig({
4+
test: {
5+
include: ['./packages/**/*.test.{ts,tsx}'],
6+
},
7+
})

0 commit comments

Comments
 (0)