当我运行
jest
时,它总是打印
ts-jest[config] (WARN) message TS151001:
If you have issues related to imports, you should consider setting `esModuleInterop` to `true` in your
TypeScript configuration file (usually `tsconfig.json`).
See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information.
我不想将
esModuleInterop
设置为 true
。
我将
--silent
视为抑制警告的建议,但这也会抑制我所做的每一个 console.log
,这是我不想要的。 (由于某种原因,设置 --silent
甚至不会抑制我的警告)
如何在保留
console.log
输出的同时禁用 Jest 中的所有警告或此特定警告?
您可以将其添加到您的 jest.config 中来消除该警告:
module.exports = {
globals: {
'ts-jest': {
diagnostics: {
warnOnly: true,
},
},
},
}