How to execute only one test spec with angular-cli

前端 未结 10 746
执笔经年
执笔经年 2020-12-02 06:00

I have Angular2 project build with Angular-CLI (beta 20).

Is there a way to run tests against only one selected spec file?

I used to have a project based on

10条回答
  •  感动是毒
    2020-12-02 06:06

    In a bash terminal I like to use the double dash. Using VS Code, you can right click on the spec file in the explorer, or on the open tab. Then select 'Copy Relative Path'. Run the command below pasting the relative path in from the clipboard.

    npm t -- --include relative/path/to/file.spec.ts
    

    The double dash signals the end of your command options for npm t and passes anything after that to the next command which is pointing to ng t. It's doesn't require any modification and quickly gives desired results.

提交回复
热议问题