New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng test not obeying single run flag #10711

Closed
jwa107 opened this Issue May 7, 2018 · 18 comments

Comments

Projects
None yet
@jwa107

jwa107 commented May 7, 2018

Versions

Angular CLI: 6.0.0
Node: 10.0.0
OS: win32 x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@angular/cdk                      6.0.1
@angular/material                 6.0.1
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

Repro steps

  • Upgrade Angular CLI to V6 (global/local)
  • Upgrade Angular to V6
  • Upgrade other dependencies
  • Ensure karma.conf.js has singleRun: false in it
  • Run ng t OR run ng t --single-run=false

Observed behavior

If ng t is run, tests will run successfully but browser window will close on finish (despite karma.conf.js having singleRun: false inside it)

If ng t --single-run=false is run, it errors: Unknown option: '--singleRun' Note that running ng t --no-single-run creates the same error.

Desired behavior

I would like the browser window to remain open, as it always did, pre-upgrade

@Ratikant01

This comment has been minimized.

Show comment
Hide comment
@Ratikant01

Ratikant01 May 8, 2018

Same issue here as well, any fix?

Ratikant01 commented May 8, 2018

Same issue here as well, any fix?

@Tataraovoleti

This comment has been minimized.

Show comment
Hide comment
@Tataraovoleti

Tataraovoleti May 8, 2018

Are you able to run unit tests after angular 6 upgrade?

Tataraovoleti commented May 8, 2018

Are you able to run unit tests after angular 6 upgrade?

@JohannesHoppe

This comment has been minimized.

Show comment
Hide comment
@JohannesHoppe

JohannesHoppe May 8, 2018

Contributor

Same here, any solutions? It's a bit urgent.

Contributor

JohannesHoppe commented May 8, 2018

Same here, any solutions? It's a bit urgent.

@JohannesHoppe

This comment has been minimized.

Show comment
Hide comment
@JohannesHoppe

JohannesHoppe May 8, 2018

Contributor

This works:

ng test --watch

Cheers!

Contributor

JohannesHoppe commented May 8, 2018

This works:

ng test --watch

Cheers!

@WizardPC

This comment has been minimized.

Show comment
Hide comment
@WizardPC

WizardPC May 8, 2018

Same here

WizardPC commented May 8, 2018

Same here

@Tataraovoleti

This comment has been minimized.

Show comment
Hide comment
@Tataraovoleti

Tataraovoleti May 9, 2018

@JohannesHoppe are you able to get code coverage report?
While running ng test i m getting error in test.ts

import 'zone.js/dist/long-stack-trace-zone';

Chrome 66.0.3359 (Windows 7 0.0.0) ERROR
{
"message": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string",
"str": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string"
}
Chrome 66.0.3359 (Windows 7 0.0.0) ERROR
{
"message": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string",
"str": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string"
}

Chrome 66.0.3359 (Windows 7 0.0.0) ERROR
{
"message": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string",
"str": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string"
}

Tataraovoleti commented May 9, 2018

@JohannesHoppe are you able to get code coverage report?
While running ng test i m getting error in test.ts

import 'zone.js/dist/long-stack-trace-zone';

Chrome 66.0.3359 (Windows 7 0.0.0) ERROR
{
"message": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string",
"str": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string"
}
Chrome 66.0.3359 (Windows 7 0.0.0) ERROR
{
"message": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string",
"str": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string"
}

Chrome 66.0.3359 (Windows 7 0.0.0) ERROR
{
"message": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string",
"str": "Uncaught SyntaxError: Unexpected string\nat test.ts:2:8\n\nSyntaxError: Unexpected string"
}

@JohannesHoppe

This comment has been minimized.

Show comment
Hide comment
@JohannesHoppe

JohannesHoppe May 9, 2018

Contributor

@Tataraovoleti
Sure, ng test --watch --code-coverage gives me watch-mode and code-coverage.
It's located in './coverage'

Contributor

JohannesHoppe commented May 9, 2018

@Tataraovoleti
Sure, ng test --watch --code-coverage gives me watch-mode and code-coverage.
It's located in './coverage'

@Tataraovoleti

This comment has been minimized.

Show comment
Hide comment
@Tataraovoleti

Tataraovoleti May 9, 2018

Can you please provide me your karma.conf.js configuration?
Did you configure preProcessors in karma.conf.js ?

Tataraovoleti commented May 9, 2018

Can you please provide me your karma.conf.js configuration?
Did you configure preProcessors in karma.conf.js ?

@JohannesHoppe

This comment has been minimized.

Show comment
Hide comment
@JohannesHoppe

JohannesHoppe May 9, 2018

Contributor

It's the default:

// 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('@angular-devkit/build-angular/plugins/karma')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};
Contributor

JohannesHoppe commented May 9, 2018

It's the default:

// 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('@angular-devkit/build-angular/plugins/karma')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};
@Tataraovoleti

This comment has been minimized.

Show comment
Hide comment
@Tataraovoleti

Tataraovoleti May 9, 2018

Hi @JohannesHoppe
Thank you , this configuration is working for me.

Tataraovoleti commented May 9, 2018

Hi @JohannesHoppe
Thank you , this configuration is working for me.

@mmenik

This comment has been minimized.

Show comment
Hide comment
@mmenik

mmenik May 9, 2018

I created a new project with Angular CLI 6.0, I have not modified the Karma configuration file.
I confirm that when the test ends google closes

ng test --watch is a workaround, we wait for fix, thks

mmenik commented May 9, 2018

I created a new project with Angular CLI 6.0, I have not modified the Karma configuration file.
I confirm that when the test ends google closes

ng test --watch is a workaround, we wait for fix, thks

@Tataraovoleti

This comment has been minimized.

Show comment
Hide comment
@Tataraovoleti

Tataraovoleti May 9, 2018

is ng test --single-run is equivalent to ng test now in angular6?
I observed same behavior.

Tataraovoleti commented May 9, 2018

is ng test --single-run is equivalent to ng test now in angular6?
I observed same behavior.

@jordanpowell88

This comment has been minimized.

Show comment
Hide comment
@jordanpowell88

jordanpowell88 May 15, 2018

I'm experiencing same issue after upgrading. ng test --watch works like ng test did before upgrade. Is this the expected behavior in angular 6?

jordanpowell88 commented May 15, 2018

I'm experiencing same issue after upgrading. ng test --watch works like ng test did before upgrade. Is this the expected behavior in angular 6?

@Gerros

This comment has been minimized.

Show comment
Hide comment
@Gerros

Gerros May 17, 2018

The wiki of the angular-cli says:
You can run tests a single time via --watch=false
https://github.com/angular/angular-cli/wiki/test
tried it out and it works

Gerros commented May 17, 2018

The wiki of the angular-cli says:
You can run tests a single time via --watch=false
https://github.com/angular/angular-cli/wiki/test
tried it out and it works

@jwa107

This comment has been minimized.

Show comment
Hide comment
@jwa107

jwa107 May 17, 2018

@Gerros The issue is that ng test no longer observes the singleRun flag in the karma configuration, and instead forces the tests into a single-run. So the problem is that the tests ALWAYS single-run now (unless you specify --watch as a command line flag)

jwa107 commented May 17, 2018

@Gerros The issue is that ng test no longer observes the singleRun flag in the karma configuration, and instead forces the tests into a single-run. So the problem is that the tests ALWAYS single-run now (unless you specify --watch as a command line flag)

@clydin

This comment has been minimized.

Show comment
Hide comment
@clydin

clydin May 17, 2018

Member

@jwa107 This should be corrected in 6.0.1. The singleRun karma option is only changed if the watch option is explicitly used. The single run command line flag no longer exists in v6.

If issues still presents with the latest version of the CLI, please open a new issue detailing the problem.

Member

clydin commented May 17, 2018

@jwa107 This should be corrected in 6.0.1. The singleRun karma option is only changed if the watch option is explicitly used. The single run command line flag no longer exists in v6.

If issues still presents with the latest version of the CLI, please open a new issue detailing the problem.

@rkrisztian

This comment has been minimized.

Show comment
Hide comment
@rkrisztian

rkrisztian May 24, 2018

--no-watch should also work (more elegant).

rkrisztian commented May 24, 2018

--no-watch should also work (more elegant).

@pumano

This comment has been minimized.

Show comment
Hide comment
@pumano

pumano May 28, 2018

I switch ng test --single-run to ng test --watch=false and it is works good.

pumano commented May 28, 2018

I switch ng test --single-run to ng test --watch=false and it is works good.

eninja added a commit to eninja/MeteoPoland-Angular that referenced this issue Jun 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment