0

I have a TypeScript project that contains a bunch of files in different directories all located under src/.

Is it possible to write a Jest test so that it only returns success if each *.tsx file found under the parent directory (src/) has a corresponding *.spec.tsx test file?

In other words if I have the following 3 files:

src/index.tsx
src/foo.tsx
src/folder/component.tsx

The Jest test would fail until such time that the following files are created:

src/index.spec.tsx
src/foo.spec.tsx
src/folder/component.spec.tsx
4

1 回答 1

1

我最终使用

import fs from 'fs';

然后使用fs.readdirandfs.statSync确定文件是文件还是目录,以便我可以递归地查看src/路径中的每个位置。

于 2018-11-04T01:29:43.700 回答