首页 > 解决方案 > 用于 NodeJS 应用的 Azure Pipeline 中的 Karma 启动

问题描述

我有一个 NodeJS (FlexServices) 应用程序,我需要执行单元测试。

这是我的 karma.conf.js

module.exports = function(config) {
    config.set({
        frameworks: ["jasmine", "karma-typescript"],
        files: [
            { pattern: "src/**/*.ts" }
        ],

        preprocessors: {
            "**/*.ts": ["karma-typescript"]
        },
        reporters: ["progress", "karma-typescript"],
        browsers: ["Chrome"],
        singleRun: true
    });
};

我拥有的管道目前正在本地 Windows 服务器上运行。在我运行karma start --single-run命令之前,我安装了 karma cli。

- task: Npm@1
  displayName: "npm install karma cli"
  inputs:
    command: 'custom'
    customCommand: 'install -g karma-cli'

当我运行我的管道时,我从 npm 收到以下错误日志。

npm ERR! errno 1
> test-flex@2.2.0 test E:\ADOAgents\Agent1\_work\3185\s
npm ERR! test-flex@2.2.0 test: `karma start --single-run`
> karma start --single-run
npm ERR! Exit status 1

npm ERR! 
29 04 2021 10:35:45.388:INFO [compiler.karma-typescript]: Compiling project using Typescript 3.9.9
npm ERR! Failed at the test-flex@2.2.0 test script.
29 04 2021 10:35:50.633:INFO [compiler.karma-typescript]: Compiled 12 files in 5230 ms.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
29 04 2021 10:35:51.532:INFO [bundler.karma-typescript]: Bundled imports for 11 file(s) in 388 ms.

29 04 2021 10:35:51.977:INFO [karma-server]: Karma v4.4.1 server started at http://0.0.0.0:9876/
npm ERR! A complete log of this run can be found in:
29 04 2021 10:35:51.978:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
npm ERR!     C:\Users\svc-teamfbuild\AppData\Roaming\npm-cache\_logs\2021-04-29T14_36_56_065Z-debug.log
29 04 2021 10:35:51.988:INFO [launcher]: Starting browser Chrome
29 04 2021 10:36:52.006:WARN [launcher]: Chrome have not captured in 60000 ms, killing.
29 04 2021 10:36:54.015:WARN [launcher]: Chrome was not killed in 2000 ms, sending SIGKILL.
29 04 2021 10:36:56.018:WARN [launcher]: Chrome was not killed by SIGKILL in 2000 ms, continuing.

我错过了一些东西来让它工作吗?

标签: node.jsazure-devopsazure-pipelines

解决方案


推荐阅读