Skip to content

Commit 4efa9e1

Browse files
committed
test: set up example with ts-transformer-keys
1 parent fc0e8a8 commit 4efa9e1

4 files changed

Lines changed: 37 additions & 0 deletions

File tree

examples/package-lock.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { TsCompilerInstance } from 'ts-jest'
2+
import keysTransformer from 'ts-transformer-keys/transformer'
3+
import type { TransformationContext } from 'typescript'
4+
5+
export const version = 1
6+
export const name = 'my-key-transformer'
7+
8+
export function factory(compilerInstance: TsCompilerInstance) {
9+
return (ctx: TransformationContext) => {
10+
// @ts-expect-error testing purpose
11+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12+
return keysTransformer(compilerInstance.program!)(ctx)
13+
}
14+
}

examples/react-app/jest.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { createDefaultPreset } from 'ts-jest'
33

44
const defaultPreset = createDefaultPreset({
55
tsconfig: 'tsconfig.spec.json',
6+
astTransformers: {
7+
before: ['hello-transformer.ts'],
8+
},
69
})
710

811
export default {

examples/react-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"jest": "^29.7.0",
3030
"jest-environment-jsdom": "^29.7.0",
3131
"ts-jest": "^29.4.0",
32+
"ts-transformer-keys": "^0.4.4",
3233
"typescript": "~5.8.3",
3334
"vite": "^6.3.5"
3435
}

0 commit comments

Comments
 (0)