angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng test --single-run doesn't work on TFS CI build?

Open georgeedwards opened this issue 9 years ago • 22 comments

Please provide us with the following information:

OS?

Windows10 x64 TFS

Versions.

ng --version: 1.0.0-beta.21 node --version: v5.11.0

Repro steps.

Standard app

The log given by the failure.

2016-12-08T14:21:16.6627730Z ##[section]Starting: npm test
2016-12-08T14:21:16.6637734Z ==============================================================================
2016-12-08T14:21:16.6637734Z Task         : npm
2016-12-08T14:21:16.6637734Z Description  : Run a npm command
2016-12-08T14:21:16.6637734Z Version      : 0.2.20
2016-12-08T14:21:16.6637734Z Author       : Microsoft Corporation
2016-12-08T14:21:16.6637734Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613746)
2016-12-08T14:21:16.6637734Z ==============================================================================
2016-12-08T14:21:16.9697740Z [command]C:\Program Files\nodejs\npm.cmd config list
2016-12-08T14:21:18.3847749Z ; cli configs
2016-12-08T14:21:18.3847749Z user-agent = "npm/3.8.6 node/v5.11.0 win32 x64"
2016-12-08T14:21:18.3847749Z 
2016-12-08T14:21:18.3847749Z ; environment configs
2016-12-08T14:21:18.3847749Z cache = "C:\\NPM\\Cache"
2016-12-08T14:21:18.3847749Z prefix = "C:\\NPM\\Modules"
2016-12-08T14:21:18.3847749Z 
2016-12-08T14:21:18.3847749Z ; globalconfig C:\NPM\Modules\etc\npmrc
2016-12-08T14:21:18.3847749Z registry = "http://registry.npmjs.org/"
2016-12-08T14:21:18.3847749Z 
2016-12-08T14:21:18.3847749Z ; builtin config undefined
2016-12-08T14:21:18.3857747Z 
2016-12-08T14:21:18.3857747Z ; node bin location = C:\Program Files\nodejs\node.exe
2016-12-08T14:21:18.3857747Z ; cwd = C:\a\1\s
2016-12-08T14:21:18.3857747Z ; HOME = C:\Users\buildguest
2016-12-08T14:21:18.3857747Z ; "npm config ls -l" to show all defaults.
2016-12-08T14:21:18.3857747Z 
2016-12-08T14:21:18.4049530Z [command]C:\Program Files\nodejs\npm.cmd test
2016-12-08T14:21:19.9407747Z 
2016-12-08T14:21:19.9407747Z > [email protected] test C:\a\1\s
2016-12-08T14:21:19.9407747Z > ng test --single-run
2016-12-08T14:21:19.9407747Z 
2016-12-08T14:21:59.8347746Z 08 12 2016 14:21:59.830:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
2016-12-08T14:21:59.8357790Z 08 12 2016 14:21:59.834:INFO [launcher]: Launching browser Chrome with unlimited concurrency
2016-12-08T14:21:59.8427793Z 08 12 2016 14:21:59.842:INFO [launcher]: Starting browser Chrome
2016-12-08T14:22:59.8430882Z 08 12 2016 14:22:59.843:WARN [launcher]: Chrome have not captured in 60000 ms, killing.
2016-12-08T14:23:01.8443962Z 08 12 2016 14:23:01.844:WARN [launcher]: Chrome was not killed in 2000 ms, sending SIGKILL.
2016-12-08T14:23:03.8459047Z 08 12 2016 14:23:03.845:WARN [launcher]: Chrome was not killed by SIGKILL in 2000 ms, continuing.
2016-12-08T14:23:04.4549756Z npm ERR! Test failed.  See above for more details.
2016-12-08T14:23:04.4909723Z ##[error]npm failed with error: C:\Program Files\nodejs\npm.cmd failed with return code: 1
2016-12-08T14:23:04.4960390Z ##[section]Finishing: npm test

Mention any other details that might be useful.

My project builds and tests fine on my local machine, but when pushed to our TFS (Visual Studio Team Services) server, no tests run, that build step fails and the command seems to time out?


Thanks! We'll be in touch soon.

georgeedwards avatar Dec 08 '16 16:12 georgeedwards

FWIW I have beta.22 building/testing on TFS 2015 without issue (so far, anyway). Do you have other TFS running karma tests via Chrome?

mattdistefano avatar Dec 08 '16 17:12 mattdistefano

@mattdistefano Would you mind sharing your test "build step"? I had karma running fine before I started using the angular-cli. Do you use a hosted or custom build machine?

georgeedwards avatar Dec 08 '16 17:12 georgeedwards

We have an on-prem installation. TFS 2015 update 3. Our test step is just a npm command task running run test (with "test": "ng test -sr -cc" in the package.json scripts), which I think is what you're already doing. Maybe Chrome just needs to be updated?

mattdistefano avatar Dec 08 '16 17:12 mattdistefano

This seems to be an issue related to TFS. I'm closing this.

hansl avatar Dec 08 '16 18:12 hansl

well, I've just run ng test on chrome 54, angular-cli.beta-21 and everything was ok, but my college reported me, that after updating chrome to v55, ng test stopped working (I've verified that on my machine as well)

ng test --single-run=true

##teamcity[blockOpened name='JavaScript Unit Tests']
09 12 2016 09:44:30.356:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
09 12 2016 09:44:30.358:INFO [launcher]: Launching browser Chrome with unlimited concurrency
09 12 2016 09:44:30.365:INFO [launcher]: Starting browser Chrome
09 12 2016 09:44:33.500:INFO [Chrome 55.0.2883 (Windows 10 0.0.0)]: Connected on socket /#tAuHv0L6EfMLbgqpAAAA with id 87965885
Chrome 55.0.2883 (Windows 10 0.0.0): Executed 0 of 0 SUCCESS (0 secs / 0 secs)
Chrome 55.0.2883 (Windows 10 0.0.0): Executed 0 of 0 ERROR (0.004 secs / 0 secs)
##teamcity[blockClosed name='JavaScript Unit Tests']
npm ERR! Test failed.  See above for more details.

Process finished with exit code 1

compared to this on chrome v54:

ng test --single-run=true

##teamcity[blockOpened name='JavaScript Unit Tests']
09 12 2016 09:41:28.726:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
09 12 2016 09:41:28.729:INFO [launcher]: Launching browser Chrome with unlimited concurrency
09 12 2016 09:41:28.737:INFO [launcher]: Starting browser Chrome
09 12 2016 09:41:31.944:INFO [Chrome 54.0.2840 (Windows 10 0.0.0)]: Connected on socket /#jqTKwPkzVOs0plrNAAAA with id 18698694
Chrome 54.0.2840 (Windows 10 0.0.0): Executed 0 of 2 SUCCESS (0 secs / 0 secs)
Chrome 54.0.2840 (Windows 10 0.0.0): Executed 1 of 2 SUCCESS (0 secs / 0.003 secs)
Chrome 54.0.2840 (Windows 10 0.0.0): Executed 2 of 2 SUCCESS (0 secs / 0.003 secs)
Chrome 54.0.2840 (Windows 10 0.0.0): Executed 2 of 2 SUCCESS (0.011 secs / 0.003 secs)
##teamcity[testSuiteStarted name='Basic expression.Chrome 54.0.2840 (Windows 10 0.0.0)']
 ##teamcity[testStarted name='should display basic EQUAL expression']
 ##teamcity[testFinished name='should display basic EQUAL expression' duration='3']
 ##teamcity[testStarted name='should display logic AND operation over 2 equals expressions']
 ##teamcity[testFinished name='should display logic AND operation over 2 equals expressions' duration='0']
 ##teamcity[testSuiteFinished name='Basic expression.Chrome 54.0.2840 (Windows 10 0.0.0)']
##teamcity[blockClosed name='JavaScript Unit Tests']

Process finished with exit code 0

castamir avatar Dec 09 '16 08:12 castamir

@castamir As a workaround, is there a way of specifying the chrome version? My local machine is running v54. @hansl So this seems like it may be a Chrome v55 compatibility thing?

georgeedwards avatar Dec 11 '16 09:12 georgeedwards

@georgeedwards to make it work again, I had to add following code into karma.conf.js

mime: { 'text/x-typescript': ['ts','tsx'] },

castamir avatar Dec 11 '16 18:12 castamir

@castamir I already had that in my karma.conf.js file? reproduced in full below:

// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', 'angular-cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-remap-istanbul'),
      require('angular-cli/plugins/karma')
    ],
    files: [
      { pattern: './client/src/test.ts', watched: false }
    ],
    preprocessors: {
      './client/src/test.ts': ['angular-cli']
    },
    mime: {
      'text/x-typescript': ['ts','tsx']
    },
    remapIstanbulReporter: {
      reports: {
        html: 'coverage',
        lcovonly: './coverage/coverage.lcov'
      }
    },
    angularCli: {
      config: './angular-cli.json',
      environment: 'dev'
    },
    reporters: config.angularCli && config.angularCli.codeCoverage
              ? ['progress', 'karma-remap-istanbul']
              : ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

georgeedwards avatar Dec 14 '16 16:12 georgeedwards

@georgeedwards try tweaking some of the timeout settings: browserDisconnectTimeout: 100000, browserNoActivityTimeout: 100000, For example. I believe there's another one that might be relevant. If your TFS box is slow, it might be timing out while compiling the webpack bundle.

mattdistefano avatar Dec 14 '16 17:12 mattdistefano

In case of TFS, check if there are no read-only files in dist folder. I had problems with this in past (I have switched this project to git so I don't have to worry about this any more).

castamir avatar Dec 15 '16 05:12 castamir

I am using git (so shouldn't have read only files?) and have added @mattdistefano 's suggestions, so that my karma.conf.js reads:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', 'angular-cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-remap-istanbul'),
      require('angular-cli/plugins/karma')
    ],
    files: [
      { pattern: './client/src/test.ts', watched: false }
    ],
    preprocessors: {
      './client/src/test.ts': ['angular-cli']
    },
    mime: {
      'text/x-typescript': ['ts','tsx']
    },
    remapIstanbulReporter: {
      reports: {
        html: 'coverage',
        lcovonly: './coverage/coverage.lcov'
      }
    },
    angularCli: {
      config: './angular-cli.json',
      environment: 'dev'
    },
    reporters: config.angularCli && config.angularCli.codeCoverage
              ? ['progress', 'karma-remap-istanbul']
              : ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false,
    browserDisconnectTimeout: 100000, 
    browserNoActivityTimeout: 100000,
  });
};

However, I still get this failed build step when running ng test -sr:

2016-12-17T10:26:24.6848369Z ##[section]Starting: npm run
2016-12-17T10:26:24.6848369Z ==============================================================================
2016-12-17T10:26:24.6848369Z Task         : npm
2016-12-17T10:26:24.6848369Z Description  : Run a npm command
2016-12-17T10:26:24.6848369Z Version      : 0.2.20
2016-12-17T10:26:24.6848369Z Author       : Microsoft Corporation
2016-12-17T10:26:24.6848369Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613746)
2016-12-17T10:26:24.6848369Z ==============================================================================
2016-12-17T10:26:24.9973438Z [command]C:\Program Files\nodejs\npm.cmd config list
2016-12-17T10:26:26.3886139Z ; cli configs
2016-12-17T10:26:26.3886139Z user-agent = "npm/3.8.6 node/v5.11.0 win32 x64"
2016-12-17T10:26:26.3886139Z 
2016-12-17T10:26:26.3886139Z ; environment configs
2016-12-17T10:26:26.3886139Z cache = "C:\\NPM\\Cache"
2016-12-17T10:26:26.3886139Z prefix = "C:\\NPM\\Modules"
2016-12-17T10:26:26.3886139Z 
2016-12-17T10:26:26.3886139Z ; globalconfig C:\NPM\Modules\etc\npmrc
2016-12-17T10:26:26.3886139Z registry = "http://registry.npmjs.org/"
2016-12-17T10:26:26.3886139Z 
2016-12-17T10:26:26.3886139Z ; builtin config undefined
2016-12-17T10:26:26.3886139Z 
2016-12-17T10:26:26.3886139Z ; node bin location = C:\Program Files\nodejs\node.exe
2016-12-17T10:26:26.3886139Z ; cwd = C:\a\1\s
2016-12-17T10:26:26.3886139Z ; HOME = C:\Users\buildguest
2016-12-17T10:26:26.3886139Z ; "npm config ls -l" to show all defaults.
2016-12-17T10:26:26.3886139Z 
2016-12-17T10:26:26.4036595Z [command]C:\Program Files\nodejs\npm.cmd run test
2016-12-17T10:26:27.8723906Z 
2016-12-17T10:26:27.8723906Z > [email protected] test C:\a\1\s
2016-12-17T10:26:27.8723906Z > ng test -sr
2016-12-17T10:26:27.8723906Z 
2016-12-17T10:27:21.5606212Z 17 12 2016 10:27:21.543:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
2016-12-17T10:27:21.5606212Z 17 12 2016 10:27:21.558:INFO [launcher]: Launching browser Chrome with unlimited concurrency
2016-12-17T10:27:21.5606212Z 17 12 2016 10:27:21.558:INFO [launcher]: Starting browser Chrome
2016-12-17T10:28:21.5597289Z 17 12 2016 10:28:21.559:WARN [launcher]: Chrome have not captured in 60000 ms, killing.
2016-12-17T10:28:23.5676984Z 17 12 2016 10:28:23.567:WARN [launcher]: Chrome was not killed in 2000 ms, sending SIGKILL.
2016-12-17T10:28:25.5756492Z 17 12 2016 10:28:25.575:WARN [launcher]: Chrome was not killed by SIGKILL in 2000 ms, continuing.
2016-12-17T10:28:26.4603438Z 
2016-12-17T10:28:26.4603438Z npm ERR! Windows_NT 6.3.9600
2016-12-17T10:28:26.4603438Z npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
2016-12-17T10:28:26.4603438Z npm ERR! node v5.11.0
2016-12-17T10:28:26.4603438Z npm ERR! npm  v3.8.6
2016-12-17T10:28:26.4603438Z npm ERR! code ELIFECYCLE
2016-12-17T10:28:26.4603438Z npm ERR! [email protected] test: `ng test -sr`
2016-12-17T10:28:26.4603438Z npm ERR! Exit status 1

I can't see from the logs which version of Chrome is being used? The test command seems to have opened Chrome for almost exactly a minute without executing any tests before giving up...

georgeedwards avatar Dec 18 '16 10:12 georgeedwards

@mattdistefano @hansl @castamir Any other ideas what this could be? Until we have fixed this, I am really not sure we can rule out that this is an issue with the cli...

georgeedwards avatar Dec 21 '16 10:12 georgeedwards

@mattdistefano @hansl @castamir I am still facing this issue. It only occurs with ng test (ng build works fine).

Here is my most recent error log:

******************************************************************************
Starting: npm test
******************************************************************************
==============================================================================
Task         : npm
Description  : Run an npm command
Version      : 0.2.21
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613746)
==============================================================================
C:\Program Files\nodejs\npm.cmd config list
; cli configs
user-agent = "npm/3.10.8 node/v6.9.1 win32 x64"

; environment configs
cache = "C:\\NPM\\Cache"
prefix = "C:\\NPM\\Modules"

; globalconfig C:\NPM\Modules\etc\npmrc
registry = "http://registry.npmjs.org/"

; builtin config undefined

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\a\1\s
; HOME = C:\Users\buildguest
; "npm config ls -l" to show all defaults.

C:\Program Files\nodejs\npm.cmd test

> [email protected] test C:\a\1\s
> ng test -sr && yarn run test:server

  0% compiling 10% building modules 0/1 modules 1 active multi C:\a\1\s\client\src\main.ts                                   10% building modules 1/1 modules 0 active 10% building modules 1/2 modules 1 active multi C:\a\1\s\client\src\styles.css                                      10% building modules 2/2 modules 0 active 10% building modules 2/3 modules 1 active ...dex.js!C:\a\1\s\client\src\styles.css                                          10% building modules 3/3 modules 0 active 10% building modules 3/4 modules 1 active ....
01 04 2017 18:20:26.476:INFO [launcher]: Launching browser Chrome with unlimited concurrency
01 04 2017 18:20:26.780:INFO [launcher]: Starting browser Chrome
01 04 2017 18:21:26.781:WARN [launcher]: Chrome have not captured in 60000 ms, killing.
01 04 2017 18:21:28.784:WARN [launcher]: Chrome was not killed in 2000 ms, sending SIGKILL.
01 04 2017 18:21:30.785:WARN [launcher]: Chrome was not killed by SIGKILL in 2000 ms, continuing.
npm ERR! Test failed.  See above for more details.
npm failed with error: C:\Program Files\nodejs\npm.cmd failed with return code: 1
******************************************************************************
Finishing: npm test
******************************************************************************

georgeedwards avatar Apr 01 '17 18:04 georgeedwards

Hi,

I am trying to build our angular project with TFS, at my local everything is working but trying to learn how to integrate TFS to my angular-cli. As I am totally new to TFS If you can help me with the build, what steps need to be taken it will be a great help.

Thanks, Shobhit

shoagraw avatar Apr 21 '17 00:04 shoagraw

@shoagraw from my personal experiance, I recommend you NOT to use TFS (and related VCS) because of file locking and problems with branching.

And if you still want to (or have to) use TFS then you must be very carefull on what you put under version control.


And if you won't do anything special (like adding additional custom node scripts) you should be ok with what angular-cli offers you by default. Just create a new project using ng new NAME and use commands from generated package.json file

castamir avatar Apr 21 '17 19:04 castamir

@castamir Just FYI the last couple versions of TFS have supported git repos.

@shoagraw It depends on what version of TFS you have. If you're using 2015+, the easiest option is to specify angular cli as a dev dependency in your package.json (this may already be there), set up a build command as a script in your package.json, then in TFS add a npm install step, followed by a npm run step, with your script as the command. That would perform the build. You can use similar steps for running unit tests, though it helps to output test/coverage reports in a format that TFS can consume natively.

mattdistefano avatar Apr 21 '17 20:04 mattdistefano

@mattdistefano It's probalby an off topic, but git repo under tfs is a bad idea (extremly poor git support in VS2015, poor support in VS2017 and ustable TFS support in IDEA related IDEs does not help either). Working with git only and integrate (as a fallback) to TFS using eg. git-tf is IMHO better way.

Btw TFS allows git repos, but those who use TFS usually have TF repos and mixing TF and GIT is not supported in VS.

castamir avatar Apr 21 '17 20:04 castamir

@castamir YMMV but we've been using it successfully with a number of projects for a while now. The old TFVC/VSS was a pain, but the git support in TFS2015 and above has been pretty solid for us with both Mac and Windows clients, though mostly via git command line (and the VSCode extension). The PR workflow is pretty comparable to github or stash, and the build/release tooling does a surprisingly good job of handling different project types (.NET, java, node + a bunch of node-based FE tools - angular cli, gulp, webpack, etc).

mattdistefano avatar Apr 21 '17 22:04 mattdistefano

Thanks everyone for replying, In our company Visa we use TFS as our Build server so I am trying to make it work for our angular projects the way it build the .net projects.

I am working on it. and got start, will keep you posted how it goes.

Thanks again. Shobhit

On Fri, Apr 21, 2017 at 3:37 PM, Matt Distefano [email protected] wrote:

@castamir https://github.com/castamir YMMV but we've been using it successfully with a number of projects for a while now. The old TFVC/VSS was a pain, but the git support in TFS2015 and above has been pretty solid for us with both Mac and Windows clients, though mostly via git command line (and the VSCode extension). The PR workflow is pretty comparable to github or stash, and the build/release tooling does a surprisingly good job of handling different project types (.NET, java, node + a bunch of node-based FE tools - angular cli, gulp, webpack, etc).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/3474#issuecomment-296321015, or mute the thread https://github.com/notifications/unsubscribe-auth/AC-Fj3-7J4Vk0_qhb0E52NwxM9Y0nlRtks5ryS-fgaJpZM4LIB4u .

-- Shobhit.Agrawal +1 425 445 3986 Keep Smiling.....[:)]

shoagraw avatar Apr 21 '17 23:04 shoagraw

@shoagraw it'll be really interesting for us to know how you set up the Build server with angular-cli in .net.

marekdano avatar Apr 27 '17 20:04 marekdano