Answered by:
Adding npm tests to Build fails

Question
-
I have a build pipeline that works which contains the following steps
1. .NET Core Restore
2. .NET Core Build
3. .NET Core Test
4. Publish Test Results
5. .Net Core PublishNow I want to add a couple of additional steps to run the NPM tests. I have a package.json that defines all of the typical commands, including test and test-single-run. It has references to jasmine-core, karma, etc. I can post full files if someone wants to see them. From the command line on my machine I can run the npm run test-single-run command and it works and executes the tests as expected.
I added 3 steps to the build pipeline above after step 4, 2 NPM steps and another Publish Test Results (don't know if/how this works with 3 different sources, but that is not my problem right now).
The first NPM step runs the command install and has the Working folder with package.json as src/Cranalytics.
The second NPM step runs custom with the command line arguments of run test-single-run and also has the same Working folder specified.The first NPM command runs without any errors and I can see it pull down a bunch of stuff. The second one errors with the following:
C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" run test-single-run"> Cranalytics@1.0.0 test-single-run d:\a\1\s\src\Cranalytics> karma start wwwroot/karma.conf.js --single-run[33m07 07 2017 15:13:06.270:WARN [watcher]: [39mPattern "d:/a/1/s/src/Cranalytics/wwwroot/lib/ngInfiniteScroll/build/ng-infinite-scroll.min.js" does not match any file.[32m07 07 2017 15:13:06.759:INFO [karma]: [39mKarma v1.7.0 server started at http://0.0.0.0:9876/[32m07 07 2017 15:13:06.760:INFO [launcher]: [39mLaunching browser Chrome with unlimited concurrency[32m07 07 2017 15:13:06.769:INFO [launcher]: [39mStarting browser Chrome[33m07 07 2017 15:14:06.773:WARN [launcher]: [39mChrome have not captured in 60000 ms, killing.[33m07 07 2017 15:14:08.777:WARN [launcher]: [39mChrome was not killed in 2000 ms, sending SIGKILL.[33m07 07 2017 15:14:10.778:WARN [launcher]: [39mChrome was not killed by SIGKILL in 2000 ms, continuing.npm ERR! Windows_NT 10.0.14393npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test-single-run"npm ERR! node v6.10.0npm ERR! npm v3.10.10npm ERR! code ELIFECYCLEnpm ERR! Cranalytics@1.0.0 test-single-run: `karma start wwwroot/karma.conf.js --single-run`npm ERR! Exit status 1npm ERR!npm ERR! Failed at the Cranalytics@1.0.0 test-single-run script 'karma start wwwroot/karma.conf.js --single-run'.npm ERR! Make sure you have the latest version of node.js and npm installed.npm ERR! If you do, this is most likely a problem with the Cranalytics package,npm ERR! not with npm itself.npm ERR! Tell the author that this fails on your system:npm ERR! karma start wwwroot/karma.conf.js --single-runnpm ERR! You can get information on how to open an issue for this project with:npm ERR! npm bugs Cranalyticsnpm ERR! Or if that isn't available, you can get their info via:npm ERR! npm owner ls Cranalyticsnpm ERR! There is likely additional logging output above.npm ERR! Please include the following file with any support request:npm ERR! d:\a\1\s\src\Cranalytics\npm-debug.logFound npm debug log, make sure the path matches with the one in npm's output: d:\a\1\s\src\Cranalytics\npm-debug.log0 info it worked if it ends with ok1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',1 verbose cli 'run',1 verbose cli 'test-single-run' ]2 info using npm@3.10.103 info using node@v6.10.04 verbose run-script [ 'pretest-single-run',4 verbose run-script 'test-single-run',4 verbose run-script 'posttest-single-run' ]5 info lifecycle Cranalytics@1.0.0~pretest-single-run: Cranalytics@1.0.06 silly lifecycle Cranalytics@1.0.0~pretest-single-run: no script for pretest-single-run, continuing7 info lifecycle Cranalytics@1.0.0~test-single-run: Cranalytics@1.0.08 verbose lifecycle Cranalytics@1.0.0~test-single-run: unsafe-perm in lifecycle true9 verbose lifecycle Cranalytics@1.0.0~test-single-run: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;d:\a\1\s\src\Cranalytics\node_modules\.bin;C:\LR\mms\Services\Mms\Provisioner\TaskAgent\agents\2.119.1\externals\git\cmd;C:\Program Files\Microsoft MPI\Bin\;C:\Program Files (x86)\Python36-32\Scripts\;C:\Program Files (x86)\Python36-32\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Xoreax\IncrediBuild;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\nodejs\;C:\Users\VssAdministrator\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\Docker;C:\NPM\Modules;;C:\Program Files\Git LFS;C:\Program Files\CMake\bin;C:\java\ant\apache-ant-1.9.7\bin;C:\java\mav...10 verbose lifecycle Cranalytics@1.0.0~test-single-run: CWD: d:\a\1\s\src\Cranalytics11 silly lifecycle Cranalytics@1.0.0~test-single-run: Args: [ '/d /s /c', 'karma start wwwroot/karma.conf.js --single-run' ]12 silly lifecycle Cranalytics@1.0.0~test-single-run: Returned: code: 1 signal: null13 info lifecycle Cranalytics@1.0.0~test-single-run: Failed to exec test-single-run script14 verbose stack Error: Cranalytics@1.0.0 test-single-run: `karma start wwwroot/karma.conf.js --single-run`14 verbose stack Exit status 114 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)14 verbose stack at emitTwo (events.js:106:13)14 verbose stack at EventEmitter.emit (events.js:191:7)14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)14 verbose stack at emitTwo (events.js:106:13)14 verbose stack at ChildProcess.emit (events.js:191:7)14 verbose stack at maybeClose (internal/child_process.js:877:16)14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)15 verbose pkgid Cranalytics@1.0.016 verbose cwd d:\a\1\s\src\Cranalytics17 error Windows_NT 10.0.1439318 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test-single-run"19 error node v6.10.020 error npm v3.10.1021 error code ELIFECYCLE22 error Cranalytics@1.0.0 test-single-run: `karma start wwwroot/karma.conf.js --single-run`22 error Exit status 123 error Failed at the Cranalytics@1.0.0 test-single-run script 'karma start wwwroot/karma.conf.js --single-run'.23 error Make sure you have the latest version of node.js and npm installed.23 error If you do, this is most likely a problem with the Cranalytics package,23 error not with npm itself.23 error Tell the author that this fails on your system:23 error karma start wwwroot/karma.conf.js --single-run23 error You can get information on how to open an issue for this project with:23 error npm bugs Cranalytics23 error Or if that isn't available, you can get their info via:23 error npm owner ls Cranalytics23 error There is likely additional logging output above.24 verbose exit [ 1, true ]Error: C:\Program Files\nodejs\npm.cmd failed with return code: 1Friday, July 7, 2017 3:17 PM
Answers
-
Hi Paul,
You can’t run karma jasmine test on Hosted agent. You need to setup a private build agent.
Refer to this article to set up a private build agent, it’s easy: Deploy an agent on Windows
The same thread: VSTS Testing Angular with npm task
Regards
Starain
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Proposed as answer by Starian chenMicrosoft contingent staff, Moderator Monday, July 24, 2017 8:38 AM
- Marked as answer by Paul Cavacas Tuesday, July 25, 2017 12:15 PM
Monday, July 24, 2017 8:38 AMModerator