mercredi 26 avril 2017

Angular4 junit test with karma : does not load javascript

I've converted my project to angular 4 / angular-cli 1.0.0 And since then, I have a strange behavior when I want to run the tests

my config :

 @angular/cli: 1.0.1 
 node: 7.8.0
 os: win32 x64
 @angular/common: 4.0.3
 @angular/compiler: 4.0.3
 @angular/core: 4.0.3
 @angular/forms: 4.0.3
 @angular/http: 4.0.3
 @angular/platform-browser: 4.0.3
 @angular/platform-browser-dynamic: 4.0.3
 @angular/router: 4.0.3
 @angular/cli: 1.0.1
 @angular/compiler-cli: 4.0.3

my karma.config.js

 module.exports = function (config) {
   config.set({
   basePath: '',
   frameworks: ['jasmine', '@angular/cli'],
   plugins: [
    require('karma-jasmine'),
    require('karma-phantomjs-launcher'),
    require('karma-firefox-launcher'),
    require('karma-chrome-launcher'),
    require('@angular/cli/plugins/karma'),
    require('karma-jasmine-html-reporter'),
    require('karma-coverage-istanbul-reporter')
    ],
   client:{
       clearContext: false // leave Jasmine Spec Runner output visible in 
        browser
   },
   files: [
      { pattern: './src/test.ts', watched: false }
   ],
   preprocessors: {
      './src/test.ts': ['@angular/cli']
   },
   mime: {
     'text/x-typescript': ['ts','tsx']
   },   
   coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ]
   },
   reporters: config.angularCli && config.angularCli.codeCoverage
          ? ['progress', 'coverage-istanbul']
          : ['progress'],
   port: 9876,
   colors: true,
   logLevel: config.LOG_INFO,
   autoWatch: true,
   browsers: ['PhantomJS','Firefox','Chrome'],
   singleRun: false
  });
 };

when i launch test with ng test --browsers Chrome No test run (nut there is no errors),it seems that he does not find any test enter image description here

indeed , in browser , i don't see my javascripts

enter image description here

BUT when i modify one of junit test (xxx.psec.ts with an editor) (by adding a space line), the javascripts are loaded in browser enter image description here

and my tests are running enter image description here

why are not my tests running at first time?

Aucun commentaire:

Enregistrer un commentaire