Angular ng test--config要正常工作,需要进行哪些更改
例如,我有以下文件:Angular ng test--config要正常工作,需要进行哪些更改,angular,jasmine,karma-runner,karma-jasmine,angular-cli,Angular,Jasmine,Karma Runner,Karma Jasmine,Angular Cli,例如,我有以下文件: ***folder blog component*** blog.component.ts blog.component.spec.ts blog.component.domSpec.ts blog.component.html blog.component.scss ***folder xyz component*** xyz.component.ts xyz.component.spec.ts xyz.component.domSpe
***folder blog component***
blog.component.ts
blog.component.spec.ts
blog.component.domSpec.ts
blog.component.html
blog.component.scss
***folder xyz component***
xyz.component.ts
xyz.component.spec.ts
xyz.component.domSpec.ts
xyz.component.html
xyz.component.scss
我希望能够使用不同的命令运行类似*.spec.ts和*.domSpec.ts的测试。我一直无法使ng test--config工作
ng test使用标准karma.conf.js可以很好地运行所有类似*.spec.ts的测试
我一直在努力让它发挥作用:
ng test——配置karma.conf.dom.js以运行所有测试,如*.domSpec.ts
在karma.conf.dom.js中,我有以下内容:
module.exports = function (config) {
let _cliAppProcessors ={};
_cliAppProcessors[config.angularCli.app+'/test.dom.ts'] = ['@angular/cli'];
config.set({
files: [
{ pattern: './src/test.dom.ts', watched: false }
],
preprocessors: _cliAppProcessors,
const context = require.context('./', true, /\.domSpec\.ts$/);
然后在test.dom.ts中,我有以下内容:
module.exports = function (config) {
let _cliAppProcessors ={};
_cliAppProcessors[config.angularCli.app+'/test.dom.ts'] = ['@angular/cli'];
config.set({
files: [
{ pattern: './src/test.dom.ts', watched: false }
],
preprocessors: _cliAppProcessors,
const context = require.context('./', true, /\.domSpec\.ts$/);
当我运行ng test--config karma.conf.dom.js时,所有的测试都会运行,不仅仅是名为*.domSpec.ts的测试,我想在一个构建步骤中运行单元测试,在另一个构建步骤中运行使用TestBed.compileComponents()的测试。最后我得到了两个文件:test.ts和test.testbed.ts 以下是文件中唯一的区别: test.ts
const context=require.context('./',true,/\.spec\.ts$/)代码>
test.testbed.ts
const context=require.context('./',true,/\.spec\.testbed\.ts$/)代码>
我将运行“ng test”来运行单元测试,然后在命令行(Windows)上运行“copy test.testbed.ts test.ts”,然后再次运行“ng test”来运行测试台测试。很简单,我知道。我无法让“ng test--config”工作 我想在一个构建步骤中运行单元测试,在另一个构建步骤中运行使用TestBed.compileComponents()的测试。最后我得到了两个文件:test.ts和test.testbed.ts
以下是文件中唯一的区别:
test.ts
const context=require.context('./',true,/\.spec\.ts$/)代码>
test.testbed.ts
const context=require.context('./',true,/\.spec\.testbed\.ts$/)代码>
我将运行“ng test”来运行单元测试,然后在命令行(Windows)上运行“copy test.testbed.ts test.ts”,然后再次运行“ng test”来运行测试台测试。很简单,我知道。我无法让“ng test--config”工作 你到底试过什么?你看过现有的配置了吗?测试.ts
?您将如何将其全部放入注释中?这个问题。提供一个例子,解释发生了什么。你到底尝试了什么?你看过现有的配置了吗?测试.ts
?您将如何将其全部放入注释中?这个问题。提供一个例子,解释发生了什么。