'@ts-expect-error'-direktiv for TypeScript fungerer ikke inne i en Jest-test
Jeg lager en express-app ved å bruke nx og axiom. Nå prøver jeg å bruke //@ts-expect-error-direktivet, men jeg får feilen Unused '@ts-expect-error' directive både fra terminalen min og redigeringsprogrammet mitt.
dette er min test:
describe('apps', () => {
it('should return an error if you return things not in the ts
definition', () => {
expect(() => {
appNotify.get('/v1/notify/healthcheck', ( res) => {
//@ts-expect-error - notExistingProperty shold not be allowed
res.json({
notExistingProperty: true,
message: 'Welcome to notify!'
});
});
}).toThrow();
});
});
dette er min tsconfig :
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2017", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@notify/logger": ["libs/logger/src/index.ts"],
"@notify/notify-redis-client": ["libs/notify-redis-client/src/index.ts"]
},
"strict": true
},
"exclude": ["node_modules", "tmp"]
}
min TypeScript-versjon er 4.9.5
Jeg har prøvd å aktivere checkJS i tsconfig, men ingenting endret seg.