ts-jest with nest-graphql-transform could not find typeFileNameSuffix with specific suffix
eliasmohammadi opened this issue · 0 comments
eliasmohammadi commented
Hi. I have a project that I write with NestJS. I used the Graphql plugin for the Field decorator, and for the e2e test, I used this link:
https://docs.nestjs.com/graphql/cli-plugin
My Problem is: when I use the default typeFileName for my files,ts-jest is happy. but if I use the custom name as the following code, ts-jest, and astTransformers could not work.
Code Structure:
- app
- user.dto.ts ----> graphql model
nest-cli.json:
{...
"plugins": [
{
"name": "@nestjs/graphql",
"options": {
"typeFileNameSuffix": [".input.ts", ".args.ts",".dto.ts"],
"introspectComments": true
}
}
]
}
}
jest.config.json:
{....
"transform": {
"^.+\\.(t|j)s$": ["ts-jest", {
"isolatedModules": false,
"astTransformers": {
"before": ["<rootDir>/jest-graphql-plugin.js"]
}
}]
....}
jest-graphql-plugin.js:
const transformer = require('@nestjs/graphql/plugin');
module.exports.name = 'nestjs-graphql-transformer';
// you should change the version number anytime you change the configuration below - otherwise, jest will not detect changes
module.exports.version = 2;
module.exports.factory = (cs) => {
return transformer.before(
{
// @nestjs/graphql/plugin options (can be empty)
},
cs.program, // "cs.tsCompiler.program" for older versions of Jest (<= v27)
);
};
plugin work with specific suffix when I want to build the project. I think ts-jest did not support typeFileNameSuffix.
How Can I config ts-jest to read specific typeFileNameSuffix for graphql?