简体   繁体   English

如何在 NX 工作区中运行特定的 angular 规范测试文件?

[英]how can i run a specific angular spec test file in NX workspace?

is there any way to run an specific angular spec test file in Nx work space?有没有办法在 Nx 工作空间中运行特定的 angular 规范测试文件?

Recently i moved my Angular 4 cli application into Nx work space.最近我将我的 Angular 4 cli 应用程序移动到 Nx 工作空间。 Previously i used fdescribe to achieve this functionality.以前我使用fdescribe来实现这个功能。
So please suggest me if there is any option to do this in Nx work space?所以请建议我是否可以在 Nx 工作空间中执行此操作?

这对我有用

 nx test --test-file example.spec.ts

这与我们为单个应用程序执行的方式相同,但请注意,您应该使用 --app='your-app-name' 和 ng test,因此最终命令如下所示,

ng test --app='app1'

For me the watch tag did the magic:对我来说,手表标签起到了神奇的作用:

ng test --watch

Before running through everything it offered me the following options:在运行所有内容之前,它为我提供了以下选项:

 › Press a to run all tests.
 › Press f to run only failed tests.
 › Press p to filter by a filename regex pattern.
 › Press t to filter by a test name regex pattern.
 › Press q to quit watch mode.
 › Press Enter to trigger a test run.

Selecting the 'p' option and typing xy.service.spec.ts worked fine.选择“p”选项并输入xy.service.spec.ts工作正常。

Note: I'm using not the latest version ( "@nrwl/nx": "7.4.0" )注意:我使用的不是最新版本( "@nrwl/nx": "7.4.0"

这对我有用:

nx run <project-name>:test --testFile=<file-name>

this worked for me:这对我有用:

nx run <project-name>:test --testFile <filename.spec.ts>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Angular/nx 工作区的上下文中运行 nestjs-console 命令 - How to run nestjs-console commands in context of Angular / nx workspace 如何在 Angular 4 中测试特定的 spec.ts 文件? - How to test a specific spec.ts file in Angular 4? 我可以在一个Nx工作区中同时为Angular和React应用程序使用NX CLI吗? - Can I use NX CLI for both Angular and React apps in one Nx workspace? 如何在进行角度单元测试时处理规范文件中的 ts 文件事件 - How can I handle events of ts file inside spec file while doing unit test of angular 如果 Angular 项目在 NX 工作区中生成且预设为“空”,如何运行 e2e 测试? - How to run e2e tests if Angular project is generated in NX workspace with preset "empty"? 为什么在 angular 的 nx 工作区中创建应用程序时找不到模块“typescript”? - Why i am getting can't find module "typescript" when creating an application inside nx workspace in angular? 如何将@angular/fire 添加到 Nx 工作区(Angular 项目)? - How add @angular/fire into Nx Workspace (Angular project)? 如何使 Angular 11 i18n 在 NRWL NX 工作区中工作。json? - How to make Angular 11 i18n work in NRWL NX workspace.json? 如何使用 NX/Nrwl 为 Angular 创建应用程序特定配置? - How do I create an app specific configuration for Angular with NX/Nrwl? 如何在 Angular 工作区配置上用属性 fileReplacements 替换文件? - How can I replace file with property fileReplacements on Angular workspace configuration?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM