VSTS使用npm任务测试Angular

时间:2017-07-10 16:05:24

标签: angularjs unit-testing continuous-integration azure-pipelines

我在VSTS中有一个构建管道,它包含以下步骤

  1. .NET Core Restore
  2. .NET Core Build
  3. .NET核心测试
  4. 发布测试结果
  5. .Net Core Publish
  6. 现在我想添加几个额外的步骤来运行npm(Angular)测试。我有一个package.json,它定义了所有典型的命令,包括test和test-single-run。它引用了jasmine-core,karma等。如果有人想看到它们,我可以发布完整的文件。从我机器上的命令行,我可以运行npm run test-single-run命令,它可以正常运行并执行测试。

    我在第4步,2 npm步骤和另一个发布测试结果之后向上面的构建管道添加了3个步骤(不知道是否/如何使用2个不同的源,但这不是我现在的问题)

    第一个npm步骤运行命令install,并将包含package.json的Working文件夹作为src / Cranalytics。
    第二个npm步骤使用run test-single-run的命令行参数运行custom,并且还指定了相同的Working文件夹。

    第一个npm命令运行没有任何错误,我可以看到它拉下了一堆东西。第二个错误如下:

        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.14393
        npm 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.0
        npm ERR! npm v3.10.10
        npm ERR! code ELIFECYCLE
        npm ERR! Cranalytics@1.0.0 test-single-run: `karma start wwwroot/karma.conf.js --single-run`
        npm ERR! Exit status 1
        npm 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-run
        npm ERR! You can get information on how to open an issue for this project with:
        npm ERR! npm bugs Cranalytics
        npm ERR! Or if that isn't available, you can get their info via:
        npm ERR! npm owner ls Cranalytics
        npm 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.log
        Found npm debug log, make sure the path matches with the one in npm's output: d:\a\1\s\src\Cranalytics\npm-debug.log
        0 info it worked if it ends with ok
        1 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.10
        3 info using node@v6.10.0
        4 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.0
        6 silly lifecycle Cranalytics@1.0.0~pretest-single-run: no script for pretest-single-run, continuing
        7 info lifecycle Cranalytics@1.0.0~test-single-run: Cranalytics@1.0.0
        8 verbose lifecycle Cranalytics@1.0.0~test-single-run: unsafe-perm in lifecycle true
        9 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\Cranalytics
        11 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: null
        13 info lifecycle Cranalytics@1.0.0~test-single-run: Failed to exec test-single-run script
        14 verbose stack Error: Cranalytics@1.0.0 test-single-run: `karma start wwwroot/karma.conf.js --single-run`
        14 verbose stack Exit status 1
        14 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.0
        16 verbose cwd d:\a\1\s\src\Cranalytics
        17 error Windows_NT 10.0.14393
        18 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.0
        20 error npm v3.10.10
        21 error code ELIFECYCLE
        22 error Cranalytics@1.0.0 test-single-run: `karma start wwwroot/karma.conf.js --single-run`
        22 error Exit status 1
        23 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-run
        23 error You can get information on how to open an issue for this project with:
        23 error npm bugs Cranalytics
        23 error Or if that isn't available, you can get their info via:
        23 error npm owner ls Cranalytics
        23 error There is likely additional logging output above.
        24 verbose exit [ 1, true ]
    
        Error: C:\Program Files\nodejs\npm.cmd failed with return code: 1
    

    将其切换为在安装了VS2017的本地代理上运行后,我在恢复步骤中收到以下错误

    2017-07-12T13:21:01.1976623Z [command]C:\dbagent\bin\dotnet.exe restore C:\dbagent\_work\2\s\Cranalytics.Tests\Cranalytics.Tests.csproj
    2017-07-12T13:21:01.2757797Z ##[error]Unable to process command '##vso[task.complete ]Dotnet command failed with non-zero exit code: 2147516564.' successfully. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=817296)
    2017-07-12T13:21:01.2757797Z ##[error]Command doesn't have valid result value.
    2017-07-12T13:21:01.3695338Z [command]C:\dbagent\bin\dotnet.exe restore C:\dbagent\_work\2\s\src\Cranalytics\Cranalytics.csproj
    2017-07-12T13:21:01.3695338Z ##[error]Unable to process command '##vso[task.complete ]Dotnet command failed with non-zero exit code: 2147516564.' successfully. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=817296)
    2017-07-12T13:21:01.3695338Z ##[error]Command doesn't have valid result value.
    

    系统路径: %SystemRoot%\ system32;%SystemRoot%;%SystemRoot%\ System32 \ Wbem;%SYSTEMROOT%\ System32 \ WindowsPowerShell \ v1.0 \; C:\ Program Files(x86)\ Microsoft SQL Server \ 110 \ Tools \ Binn \ ManagementStudio \; C:\ Program Files(x86)\ Microsoft SQL Server \ 110 \ Tools \ Binn \; C:\ Program Files \ Microsoft SQL Server \ 110 \ Tools \ Binn \; C:\ Program Files(x86)\ Microsoft SQL Server \ 110 \ DTS \ Binn \;%USERPROFILE%.dnx \ bin; C:\ Program Files \ Microsoft DNX \ Dnvm \; C:\ Program Files \ Microsoft SQL Server \ 120 \ Tools \ Binn \; C:\ Program Files \ Microsoft SQL Server \ 130 \ Tools \ Binn \; C:\ Program Files \ Git \ cmd; C:\ Program Files(x86)\ Microsoft ASP.NET \ ASP.NET Web Pages \ v1.0 \; C :\ Program Files \ dotnet \

1 个答案:

答案 0 :(得分:0)

你不能在托管代理上运行业力茉莉花测试。您需要设置私有构建代理。

请参阅此文章以设置私有构建代理,这很简单:Deploy an agent on Windows