在Ionic中为其他Angular模块添加单元测试时,业力测试无法运行

时间:2019-03-11 14:12:28

标签: node.js angular unit-testing npm karma-jasmine

我有一个在以下环境中运行的应用程序:

  • 离子:3.9.2
  • 业力:2.0.2
  • 业力茉莉花:1.1.2
  • 茉莉花:3.1.0

我的大多数课程都包含在主app.module.ts文件declarationsentryComponents中,该文件位于./src/app/app.module.ts。我最近为位于./src/second/second.module.ts的类添加了位于./src/second/pages/**/page.ts的新模块。使用命令npm run test时,失败并显示

> my-test@0.0.1 test /Users/me/proj/proj-repo
> karma start ./test-config/karma.conf.js

webpack: wait until bundle finished: 
11 03 2019 10:03:06.579:ERROR [karma]: { inspect: [Function: inspect] }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-test@0.0.1 test: `karma start ./test-config/karma.conf.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-test@0.0.1 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

这是我的karma.conf.js文件:

var webpackConfig = require('./webpack.test.js');
process.env.CHROME_BIN = require("puppeteer").executablePath();

module.exports = function(config) {
  var _config = {
    basePath: '../',

    frameworks: ['jasmine'],

    files: [
      {
        pattern: './test-config/karma-test-shim.js',
        watched: true
      },
      {
        pattern: './src/assets/**/*',
        watched: false,
        included: false,
        served: true,
        nocache: false
      }
    ],

    proxies: {
      '/assets/': '/base/src/assets/'
    },

    preprocessors: {
      './test-config/karma-test-shim.js': ['webpack', 'sourcemap']
    },

    webpack: webpackConfig,

    webpackMiddleware: {
      stats: 'errors-only'
    },

    webpackServer: {
      noInfo: true
    },

    browserConsoleLogOptions: {
      level: 'log',
      format: '%b %T: %m',
      terminal: true
    },

    jasmineNodeOpts : {
      defaultTimeoutInterval: 20000
    },

    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly', 'cobertura' ],
      fixWebpackSourcePaths: true
    },

    reporters: config.coverage ? ['kjhtml', 'dots', 'coverage-istanbul', 'junit', 'progress'] : ['kjhtml', 'dots'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    concurrency: 1,
    //browsers: ['PhantomJS'],
    captureTimeout: 600000,
    browserDisconnectTolerance: 3, 
    browserDisconnectTimeout : 600000,
    browserNoActivityTimeout : 600000,
    browsers: ['ChromeHeadless'],
    singleRun: false,
    junitReporter: {
      outputDir: 'coverage',
      useBrowserName: false
    }
  };

  config.set(_config);
};

关于如何使这些测试运行的任何见解都将是很棒的!让我知道是否需要提供更多信息。

0 个答案:

没有答案