We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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:
Three years later, this question will be answered:) It may no longer be relevant to you, I guess, but somebody will find it helpful.
There are two main points to connect di-compiler to ts-jest:
di-compiler
ts-jest
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 jest.config.js:
jest.config.js
/** @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.
Sorry, something went wrong.
No branches or pull requests
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: