我们的团队已经配置了 TypeScript 来使jest
全球可用的类型:
// tsconfig.json
{
...,
"types": ["jest", "@testing-library/jest-dom", ...]
}
这真的很好*.test.ts
文件,但今天我意识到它也接受jest
(和相关功能)在常规旧*.ts
文件——在我读完之后,这是有道理的tsconfig 文档 https://www.typescriptlang.org/tsconfig#types。是否可以限制类型的可用性(jest
在我们的例子中)到某个目录或文件子集?
// component.tsx (error - 'jest' should not be defined)
const mockFn = jest.fn();
// component.test.tsx (no error - 'jest' should be defined)
const mockFn = jest.fn();
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)