Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular ng test--config要正常工作,需要进行哪些更改_Angular_Jasmine_Karma Runner_Karma Jasmine_Angular Cli - Fatal编程技术网

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
?您将如何将其全部放入注释中?这个问题。提供一个例子,解释发生了什么。