-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jest example #10
Comments
Three years later, this question will be answered:) There are two main points to connect
let's start with the second one import type { DiOptions } from '@wessberg/di-compiler'
import { di } from '@wessber/di-compiler'
import type { TsCompilerInstance } from 'ts-jest/dist/types'
export const version = 1
export const name = '@wessberg/di-compiler'
type Options = {
isAfter?: boolean
}
export function factory(compilerInstance: TsCompilerInstance, options?: Options) {
const typescript = compilerInstance.configSet.compilerModule
const config: DiOptions = {
program: compilerInstance.program,
typescript: ts
}
const { before, after } = di(config)
if (options?.isAfter) {
return after?.[0]
}
return before?.[0]
} After that we can add this transformer to /** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
transform: {
'^.+\\.[tj]sx?$': [
'ts-jest',
{
astTransformers: {
before: [{ path: 'relative path to transformer file' }],
after: [{ path: 'relative path to transformer file', options: { isAfter: true } }],
}
}
]
}
/* Rest of your config */
} Maybe there is a better way to deal with it, but it worked for me. I hope it helps someone. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for library its awesome. But i ran into issue cant configure with jest. Can you please provide example how to setup with jest ts-jest
The text was updated successfully, but these errors were encountered: