使用不同的测试入口点

时间:2018-01-02 04:00:54

标签: angular unit-testing karma-runner angular-cli

是否有运行ng test的测试入口点与.angular-cli.json中指定的入口点不同?

https://github.com/angular/angular-cli/issues/8579#issuecomment-346313383提供了一种通过使用延迟加载的块来增加重建时间的解决方案。但是我担心将测试分成几块可能会导致错过一些测试。

理想情况下我会有两个文件: test.tstest.tmp.ts test.ts包含:

const context = require.context('./', true, /\.spec\.ts$/);

test.tmp.ts有:

const context = require.context('./app/some_module/', true, /\.spec\.ts$/);

这样,在开发过程中,我可以运行ng test --entry-point=test.tmp.ts之类的东西。理想情况下,test.tmp.ts将是git.ignored。

目前,可以致电ng test --config=different_karma.conf.js来指定其他karma.conf.js,并且在karma.conf.js内,您可以更改test.ts内的apps.0.test。但是,除非我将angular-cli.json中的test.tmp.ts入口点更改为Uncaught SyntaxError: Unexpected string at src/test.tmp.ts:3 ,否则无法成功运行测试。

我得到的错误是:

ng test -app

一种解决方案是在.angular-cli.json中创建另一个应用程序,它是具有不同入口点的第一个应用程序的副本,并调用angular-cli.json但是您必须维护两个不同的应用程序配置。

我可以每次直接更改test.ts,但可能会提交。

修改:https://stackoverflow.com/a/43669082/5464931看起来好像改变self.my_df.loc[2, "B"] = "x" 似乎不是必要的,但我似乎无法让它发挥作用。

0 个答案:

没有答案