运行 特定模块的 ng 测试
Running ng test for specific module
我有一个相当大的 Angular8 应用程序,我正在 运行ning 进行单元测试,我希望 ng test 命令 运行 仅对所有 spec.ts 文件进行测试specified/desired 模块而不是整个代码库中的所有 spec.ts 文件。我尝试在 test.ts 文件路径中指定模块名称,但它在终端中抛出模块未找到错误,但在 test.ts 文件中指定特定组件名称 运行s 测试单个组件但不适用于模块。谢谢
如果您使用的是较新版本的 Angular,您可以将 --include
用作 stated here and here
但如果您使用的是 Jasmine,则只需将字母 "f" 添加到您的 describe
- fdescribe()
.
或者在测试本身上使用它 - fit()
这样你 "focus" 只在一个测试或测试套件上 运行 只有那个。
- 导航到
src/app/test.ts
。
- 编辑这一行
const context = require.context('<MODULE_PATH>', true, /.spec\.ts$/);
我有一个相当大的 Angular8 应用程序,我正在 运行ning 进行单元测试,我希望 ng test 命令 运行 仅对所有 spec.ts 文件进行测试specified/desired 模块而不是整个代码库中的所有 spec.ts 文件。我尝试在 test.ts 文件路径中指定模块名称,但它在终端中抛出模块未找到错误,但在 test.ts 文件中指定特定组件名称 运行s 测试单个组件但不适用于模块。谢谢
如果您使用的是较新版本的 Angular,您可以将 --include
用作 stated here and here
但如果您使用的是 Jasmine,则只需将字母 "f" 添加到您的 describe
- fdescribe()
.
或者在测试本身上使用它 - fit()
这样你 "focus" 只在一个测试或测试套件上 运行 只有那个。
- 导航到
src/app/test.ts
。 - 编辑这一行
const context = require.context('<MODULE_PATH>', true, /.spec\.ts$/);