我们试图让建筑管道对角度进行单元测试,这在第一次尝试中效果很好。第二次尝试失败,并显示以下错误:
✓ should create
HeadlessChrome 74.0.3729 (Linux 0.0.0) ERROR
{
"message": "An error was thrown in afterAll\nUncaught [object Object] thrown",
"str": "An error was thrown in afterAll\nUncaught [object Object] thrown"
}
HeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 30 of 30 ERROR (0 secs / 1.145 secs)
HeadlessChrome 74.0.3729 (Linux 0.0.0) ERROR
{
"message": "An error was thrown in afterAll\nUncaught [object Object] thrown",
"str": "An error was thrown in afterAll\nUncaught [object Object] thrown"
}
每次测试均成功,但此后均发生此错误。我想知道为什么,所以我又重新运行了。成功。但是之后的构建又因相同的问题而失败。从那以后,第二个构建都失败了。
在通过Google的途中,我发现了一些似乎很相似的问题。一个人说可能会出现问题,因为测试将以随机顺序进行。因此,我禁用了您可以在下面的karma.conf.js中看到的随机顺序。
另一个人说他能够使用'karma-spec-reporter'查找错误,所以我也将它添加到了conf中。
我的conf现在看起来像这样:
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-spec-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
jasmine: {
random: false
}
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage/hts'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml', 'spec'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
以下是测试失败的日志:
2019-05-28T11:45:17.6728528Z > ng test --watch=false --browsers=ChromeHeadless
2019-05-28T11:45:17.6728557Z
2019-05-28T11:45:17.6728872Z [32m28 05 2019 11:44:41.520:INFO [karma-server]: [39mKarma v3.1.4 server started at http://0.0.0.0:9876/
2019-05-28T11:45:17.6729152Z [32m28 05 2019 11:44:41.526:INFO [launcher]: [39mLaunching browsers ChromeHeadless with concurrency unlimited
2019-05-28T11:45:17.6729727Z [32m28 05 2019 11:44:41.544:INFO [launcher]: [39mStarting browser ChromeHeadless
2019-05-28T11:45:17.6730283Z [32m28 05 2019 11:45:06.962:INFO [HeadlessChrome 74.0.3729 (Linux 0.0.0)]: [39mConnected on socket D5MowUVbw8jTkj6eAAAA with id 99860190
2019-05-28T11:45:17.6734720Z HeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 0 of 30 SUCCESS (0 secs / 0 secs)
2019-05-28T11:45:17.6735145Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 1 of 30 SUCCESS (0 secs / 0.011 secs)
2019-05-28T11:45:17.6735180Z
2019-05-28T11:45:17.6735250Z AppComponent
2019-05-28T11:45:17.6735485Z [32m✓ [39mshould create the app
2019-05-28T11:45:17.6735748Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 2 of 30 SUCCESS (0 secs / 0.012 secs)
2019-05-28T11:45:17.6735941Z
2019-05-28T11:45:17.6736003Z AuthPageComponent
2019-05-28T11:45:17.6736242Z [32m✓ [39mshould create
2019-05-28T11:45:17.6736502Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 3 of 30 SUCCESS (0 secs / 0.013 secs)
2019-05-28T11:45:17.6736531Z
2019-05-28T11:45:17.6736588Z LoggedOutComponent
2019-05-28T11:45:17.6736781Z [32m✓ [39mshould create
2019-05-28T11:45:17.6737037Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 4 of 30 SUCCESS (0 secs / 0.013 secs)
2019-05-28T11:45:17.6737078Z
2019-05-28T11:45:17.6737132Z LoginComponent
2019-05-28T11:45:17.6737329Z [32m✓ [39mshould create
2019-05-28T11:45:17.6737764Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 5 of 30 SUCCESS (0 secs / 0.045 secs)
2019-05-28T11:45:17.6737790Z
2019-05-28T11:45:17.6737852Z AuthenticationInterceptorService
2019-05-28T11:45:17.6738046Z [32m✓ [39mshould be created
2019-05-28T11:45:17.6738294Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 6 of 30 SUCCESS (0 secs / 0.055 secs)
2019-05-28T11:45:17.6738332Z
2019-05-28T11:45:17.6738386Z AuthenticationService
2019-05-28T11:45:17.6738578Z [32m✓ [39mshould be created
2019-05-28T11:45:17.6738824Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 7 of 30 SUCCESS (0 secs / 0.09 secs)
2019-05-28T11:45:17.6738851Z
2019-05-28T11:45:17.6738907Z AuthGuard
2019-05-28T11:45:17.6739091Z [32m✓ [39mshould ...
2019-05-28T11:45:17.6739977Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 8 of 30 SUCCESS (0 secs / 0.09 secs)
2019-05-28T11:45:17.6740032Z
2019-05-28T11:45:17.6740093Z HomeComponent
2019-05-28T11:45:17.6740294Z [32m✓ [39mshould create
2019-05-28T11:45:17.6740550Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 9 of 30 SUCCESS (0 secs / 0.092 secs)
2019-05-28T11:45:17.6740781Z [32m✓ [39mshould add environment into tile
2019-05-28T11:45:17.6741042Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 10 of 30 SUCCESS (0 secs / 0.13 secs)
2019-05-28T11:45:17.6741080Z
2019-05-28T11:45:17.6741116Z ConfigService
2019-05-28T11:45:17.6741333Z [32m✓ [39mshould be created
2019-05-28T11:45:17.6741594Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 11 of 30 SUCCESS (0 secs / 0.164 secs)
2019-05-28T11:45:17.6741621Z
2019-05-28T11:45:17.6741657Z ExportService
2019-05-28T11:45:17.6741869Z [32m✓ [39mshould be created
2019-05-28T11:45:17.6742531Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 12 of 30 SUCCESS (0 secs / 0.189 secs)
2019-05-28T11:45:17.6742595Z
2019-05-28T11:45:17.6742635Z HtsService
2019-05-28T11:45:17.6742889Z [32m✓ [39mshould be created
2019-05-28T11:45:17.6743330Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 13 of 30 SUCCESS (0 secs / 0.21 secs)
2019-05-28T11:45:17.6743358Z
2019-05-28T11:45:17.6743412Z IngredientsService
2019-05-28T11:45:17.6764640Z [32m✓ [39mshould be created
2019-05-28T11:45:17.6765022Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 14 of 30 SUCCESS (0 secs / 0.229 secs)
2019-05-28T11:45:17.6765074Z
2019-05-28T11:45:17.6765145Z UserService
2019-05-28T11:45:17.6765352Z [32m✓ [39mshould be created
2019-05-28T11:45:17.6765595Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 15 of 30 SUCCESS (0 secs / 0.23 secs)
2019-05-28T11:45:17.6765622Z
2019-05-28T11:45:17.6765680Z ChartsComponent
2019-05-28T11:45:17.6765864Z [32m✓ [39mshould create
2019-05-28T11:45:17.6766105Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 16 of 30 SUCCESS (0 secs / 0.232 secs)
2019-05-28T11:45:17.6766361Z
2019-05-28T11:45:17.6766422Z DataTabsComponent
2019-05-28T11:45:17.6766643Z [32m✓ [39mshould create
2019-05-28T11:45:17.6766887Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 17 of 30 SUCCESS (0 secs / 0.232 secs)
2019-05-28T11:45:17.6766914Z
2019-05-28T11:45:17.6766966Z FilterPanelComponent
2019-05-28T11:45:17.6767158Z [32m✓ [39mshould create
2019-05-28T11:45:17.6767403Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 18 of 30 SUCCESS (0 secs / 0.233 secs)
2019-05-28T11:45:17.6767533Z
2019-05-28T11:45:17.6767590Z GeneralFilterComponent
2019-05-28T11:45:17.6767794Z [32m✓ [39mshould create
2019-05-28T11:45:17.6768034Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 19 of 30 SUCCESS (0 secs / 0.233 secs)
2019-05-28T11:45:17.6768665Z [32m✓ [39mshould add a new filter when addFilter is called
2019-05-28T11:45:17.6768908Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 20 of 30 SUCCESS (0 secs / 0.234 secs)
2019-05-28T11:45:17.6769128Z [32m✓ [39mshould delete filter when call deleteFilterRow
2019-05-28T11:45:17.6769368Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 21 of 30 SUCCESS (0 secs / 0.239 secs)
2019-05-28T11:45:17.6769415Z
2019-05-28T11:45:17.6769449Z IngredientFilterComponent
2019-05-28T11:45:17.6769632Z [32m✓ [39mshould create
2019-05-28T11:45:17.6769868Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 22 of 30 SUCCESS (0 secs / 0.24 secs)
2019-05-28T11:45:17.6770111Z [32m✓ [39mshould add a new filter when addFilter is called
2019-05-28T11:45:17.6770350Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 23 of 30 SUCCESS (0 secs / 0.242 secs)
2019-05-28T11:45:17.6770555Z [32m✓ [39mshould delete filter when call deleteFilterRow
2019-05-28T11:45:17.6770812Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 24 of 30 SUCCESS (0 secs / 0.244 secs)
2019-05-28T11:45:17.6770838Z
2019-05-28T11:45:17.6770871Z PropertyFilterComponent
2019-05-28T11:45:17.6771062Z [32m✓ [39mshould create
2019-05-28T11:45:17.6771322Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 25 of 30 SUCCESS (0 secs / 0.244 secs)
2019-05-28T11:45:17.6771530Z [32m✓ [39mshould add a new filter when addFilter is called
2019-05-28T11:45:17.6771768Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 26 of 30 SUCCESS (0 secs / 0.244 secs)
2019-05-28T11:45:17.6771994Z [32m✓ [39mshould delete filter when call deleteFilterRow
2019-05-28T11:45:17.6772247Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 27 of 30 SUCCESS (0 secs / 0.244 secs)
2019-05-28T11:45:17.6772274Z
2019-05-28T11:45:17.6772306Z StandardRow
2019-05-28T11:45:17.6772518Z [32m✓ [39mshould create an instance
2019-05-28T11:45:17.6772762Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 28 of 30 SUCCESS (0 secs / 0.244 secs)
2019-05-28T11:45:17.6772787Z
2019-05-28T11:45:17.6772820Z TableComponent
2019-05-28T11:45:17.6773018Z [32m✓ [39mshould create
2019-05-28T11:45:17.6773271Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 29 of 30 SUCCESS (0 secs / 0.247 secs)
2019-05-28T11:45:17.6773298Z
2019-05-28T11:45:17.6773331Z IngredientsListComponent
2019-05-28T11:45:17.6773528Z [32m✓ [39mshould create
2019-05-28T11:45:17.6773767Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 30 of 30 SUCCESS (0 secs / 1.145 secs)
2019-05-28T11:45:17.6773792Z
2019-05-28T11:45:17.6773825Z UserComponent
2019-05-28T11:45:17.6774030Z [32m✓ [39mshould create
2019-05-28T11:45:17.6774231Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0) ERROR
2019-05-28T11:45:17.6774270Z {
2019-05-28T11:45:17.6774308Z "message": "An error was thrown in afterAll\nUncaught [object Object] thrown",
2019-05-28T11:45:17.6774365Z "str": "An error was thrown in afterAll\nUncaught [object Object] thrown"
2019-05-28T11:45:17.6774399Z }
2019-05-28T11:45:17.6774436Z HeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 30 of 30 ERROR (0 secs / 1.145 secs)
2019-05-28T11:45:17.6774490Z HeadlessChrome 74.0.3729 (Linux 0.0.0) ERROR
2019-05-28T11:45:17.6774616Z {
2019-05-28T11:45:17.6775111Z "message": "An error was thrown in afterAll\nUncaught [object Object] thrown",
2019-05-28T11:45:17.6775166Z "str": "An error was thrown in afterAll\nUncaught [object Object] thrown"
2019-05-28T11:45:17.6775220Z }
2019-05-28T11:45:17.6775508Z [31mHeadlessChrome 74.0.3729 (Linux 0.0.0) ERROR[39m
2019-05-28T11:45:17.6775550Z {
2019-05-28T11:45:17.6775606Z "message": "An error was thrown in afterAll\nUncaught [object Object] thrown",
2019-05-28T11:45:17.6775765Z "str": "An error was thrown in afterAll\nUncaught [object Object] thrown"
2019-05-28T11:45:17.6775799Z }
2019-05-28T11:45:17.6776075Z [1A[2KHeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 30 of 30 ERROR (1.242 secs / 1.145 secs)
2019-05-28T11:45:17.6776125Z
2019-05-28T11:45:17.6776370Z HeadlessChrome 74.0.3729 (Linux 0.0.0): Executed 30 of 30[31m ERROR[39m (1.242 secs / 1.145 secs)