angular 7中的Karma Jasmine单元测试问题-无法读取属性';成功';未定义的

angular 7中的Karma Jasmine单元测试问题-无法读取属性';成功';未定义的,angular,Angular,我在使用Karma和Jasmine运行ng测试时遇到问题。它会停止浏览器,当我取消运行时,它会抛出以下错误 > Cannot read property 'success' of undefined TypeError: Cannot read > property 'success' of undefined > at TestCommand.runSingleTarget (C:\workspace\uif_mdm\node_modules\@angular\cli

我在使用Karma和Jasmine运行ng测试时遇到问题。它会停止浏览器,当我取消运行时,它会抛出以下错误

> Cannot read property 'success' of undefined TypeError: Cannot read
> property 'success' of undefined
>     at TestCommand.runSingleTarget (C:\workspace\uif_mdm\node_modules\@angular\cli\models\packages\angular\cli\models\architect-command.ts:242:21)
>     at process._tickCallback (internal/process/next_tick.js:68:7)

当我卸载karma phantomjs启动器时,这个错误就消失了。还得搬走 浏览器:[PhantomJs']位于karma.conf.js中,并添加以下内容

 browsers: ['ChromeHeadlessNoSandbox'],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
      base: 'ChromeHeadless',
      flags: ['--no-sandbox']
    },
  } 

当a使用
ng test
运行单元测试时,抛出此错误。当a使用npm运行测试(测试脚本为
ng test--watch=false--code coverage
)运行单元测试时,它成功运行


ng测试中添加标志
--watch=false
已为我修复。

请显示您正在测试的内容?可能在此处解决: