Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack Karma ERROR[配置]:配置文件无效_Webpack_Karma Runner_Karma Jasmine_Aurelia - Fatal编程技术网

Webpack Karma ERROR[配置]:配置文件无效

Webpack Karma ERROR[配置]:配置文件无效,webpack,karma-runner,karma-jasmine,aurelia,Webpack,Karma Runner,Karma Jasmine,Aurelia,我正在尝试使用Karma+Jasmine对我的Aurelia(+Webpack+TypeScript)应用程序进行单元测试。我试图使用随附的测试样板 在skeleton项目上,以下npm脚本运行良好: "test": "cross-env NODE_ENV=test ./node_modules/karma/bin/karma start test/karma.conf.js" 但是当我在我的项目上尝试同样的方法时,它抛出了错误(没有进一步的stacktrace): 它不提供有关配置无效原因的

我正在尝试使用Karma+Jasmine对我的Aurelia(+Webpack+TypeScript)应用程序进行单元测试。我试图使用随附的测试样板

在skeleton项目上,以下npm脚本运行良好:

"test": "cross-env NODE_ENV=test ./node_modules/karma/bin/karma start test/karma.conf.js"
但是当我在我的项目上尝试同样的方法时,它抛出了错误(没有进一步的stacktrace):

它不提供有关配置无效原因的任何其他信息

下面是骨架附带的
karma.conf.js

"use strict";
const path = require('path');

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (e.g. files, exclude)
    basePath: __dirname,

    /*
     * Frameworks to use
     *
     * available frameworks: https://npmjs.org/browse/keyword/karma-adapter
     */
    frameworks: ['jasmine'],

    // list of files to exclude
    exclude: [ ],

    /*
     * list of files / patterns to load in the browser
     *
     * we are building the test environment in ./spec-bundle.js
     */
    files: [
      { pattern: 'spec-bundle.js', watched: false },
    ],

    /*
     * preprocess matching files before serving them to the browser
     * available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
     */
    preprocessors: {
      'spec-bundle.js': ['coverage', 'webpack', 'sourcemap']
    },

    webpack: require('../webpack.config'),

    coverageReporter: {
      reporters: [{
        type: 'json',
        subdir: '.', 
        file: 'coverage-final.json'
      }]
    },

    remapIstanbulReporter: {
      src: path.join(__dirname, 'coverage/coverage-final.json'),
      reports: {
        html: path.join(__dirname, 'coverage/')
      },
      timeoutNotCreated: 1000,
      timeoutNoMoreFiles: 1000
    },

    // Webpack please don't spam the console when running in karma!
    webpackServer: { noInfo: true},

    /*
     * test results reporter to use
     *
     * possible values: 'dots', 'progress'
     * available reporters: https://npmjs.org/browse/keyword/karma-reporter
     */
    reporters: [ 'mocha', 'coverage', 'karma-remap-istanbul' ],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    /*
     * level of logging
     * possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
     */
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,

    /*
     * start these browsers
     * available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
     */
    browsers: [
      'Chrome',
      // TODO: https://www.npmjs.com/package/karma-electron
    ],

    /*
     * Continuous Integration mode
     * if true, Karma captures browsers, runs the tests and exits
     */
    singleRun: true
  });
};
为了隔离这个问题,我还尝试在我的网站根目录下使用
karma init
生成一个新的
karma.conf.js
,我遇到了与
karma start
完全相同的错误。下面是由此生成的配置文件:

// Karma configuration
// Generated on Wed Dec 14 2016 07:50:15 GMT+0100 (W. Europe Standard Time)

module.exports = function (config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      './test/**/*Spec.js'
    ],


    // list of files to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  });
};
我正在使用以下版本的npm软件包:

"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-mocha-reporter": "^2.2.0",
"karma-remap-istanbul": "^0.2.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.0",
"typescript": "2.1.1",
"webpack": "2.1.0-beta.27", 
DEBUG [config]: Loading config C:\Path\to\my\Website\test\karma.conf.js
ERROR [config]: Invalid config file!
  TSError: ⨯ Unable to compile TypeScript
Cannot find type definition file for 'dir1'. (2688)
Cannot find type definition file for 'dir2'. (2688)
Cannot find type definition file for 'dir3'. (2688)
Cannot find type definition file for 'lang1'. (2688)
Cannot find type definition file for 'dir4'. (2688)
Cannot find type definition file for 'lang2'. (2688)
Cannot find type definition file for 'maps'. (2688)
Cannot find type definition file for 'valueConverters'. (2688)
Cannot find type definition file for 'views'. (2688)
    at getOutput (C:\Path\to\my\Website\node_modules\ts-node\src\index.ts:312:17)
    at C:\Path\to\my\Website\node_modules\ts-node\src\index.ts:343:18
    at Object.compile (C:\Path\to\my\Website\node_modules\ts-node\src\index.ts:476:19)
    at Module.m._compile (C:\Path\to\my\Website\node_modules\ts-node\src\index.ts:406:44)
    at Module._extensions..js (module.js:579:10)
    at Object.require.extensions.(anonymous function) [as .js] (C:\Path\to\my\Website\node_modules\ts-node\src\index.ts:409:12)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.parseConfig (C:\Path\to\my\Website\node_modules\karma\lib\config.js:342:22)
    at new Server (C:\Path\to\my\Website\node_modules\karma\lib\server.js:56:20)
    at Object.exports.run (C:\Path\to\my\Website\node_modules\karma\lib\cli.js:280:7)
    at Object.<anonymous> (C:\Path\to\my\Website\node_modules\karma\bin\karma:3:23)
    at Module._compile (module.js:570:32)
请建议如何解决这个问题,或者至少有更多(调试)信息需要调查

更新:
rimraf
安装
node\u模块并重新安装软件包后,获得以下堆栈跟踪:

"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-mocha-reporter": "^2.2.0",
"karma-remap-istanbul": "^0.2.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.0",
"typescript": "2.1.1",
"webpack": "2.1.0-beta.27", 
DEBUG [config]: Loading config C:\Path\to\my\Website\test\karma.conf.js
ERROR [config]: Invalid config file!
  TSError: ⨯ Unable to compile TypeScript
Cannot find type definition file for 'dir1'. (2688)
Cannot find type definition file for 'dir2'. (2688)
Cannot find type definition file for 'dir3'. (2688)
Cannot find type definition file for 'lang1'. (2688)
Cannot find type definition file for 'dir4'. (2688)
Cannot find type definition file for 'lang2'. (2688)
Cannot find type definition file for 'maps'. (2688)
Cannot find type definition file for 'valueConverters'. (2688)
Cannot find type definition file for 'views'. (2688)
    at getOutput (C:\Path\to\my\Website\node_modules\ts-node\src\index.ts:312:17)
    at C:\Path\to\my\Website\node_modules\ts-node\src\index.ts:343:18
    at Object.compile (C:\Path\to\my\Website\node_modules\ts-node\src\index.ts:476:19)
    at Module.m._compile (C:\Path\to\my\Website\node_modules\ts-node\src\index.ts:406:44)
    at Module._extensions..js (module.js:579:10)
    at Object.require.extensions.(anonymous function) [as .js] (C:\Path\to\my\Website\node_modules\ts-node\src\index.ts:409:12)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.parseConfig (C:\Path\to\my\Website\node_modules\karma\lib\config.js:342:22)
    at new Server (C:\Path\to\my\Website\node_modules\karma\lib\server.js:56:20)
    at Object.exports.run (C:\Path\to\my\Website\node_modules\karma\lib\cli.js:280:7)
    at Object.<anonymous> (C:\Path\to\my\Website\node_modules\karma\bin\karma:3:23)
    at Module._compile (module.js:570:32)
DEBUG[config]:加载配置C:\Path\to\my\Website\test\karma.conf.js
错误[config]:配置文件无效!
t错误:⨯ 无法编译类型脚本
找不到“dir1”的类型定义文件。(2688)
找不到“dir2”的类型定义文件。(2688)
找不到“dir3”的类型定义文件。(2688)
找不到“lang1”的类型定义文件。(2688)
找不到“dir4”的类型定义文件。(2688)
找不到“lang2”的类型定义文件。(2688)
找不到“映射”的类型定义文件。(2688)
找不到“valueConverters”的类型定义文件。(2688)
找不到“视图”的类型定义文件。(2688)
在getOutput(C:\Path\to\my\Website\node\u modules\ts node\src\index.ts:312:17)
在C:\Path\to\my\Website\node\u modules\ts node\src\index.ts:343:18
在Object.compile(C:\Path\to\my\Website\node\u modules\ts node\src\index.ts:476:19)
在Module.m.处编译(C:\Path\to\my\Website\node\u modules\ts node\src\index.ts:406:44)
at Module._extensions..js(Module.js:579:10)
at Object.require.extensions.(匿名函数)[as.js](C:\Path\to\my\Website\node\u modules\ts node\src\index.ts:409:12)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
at Module.require(Module.js:497:17)
根据需要(内部/module.js:20:19)
在Object.parseConfig(C:\Path\to\my\Website\node\u modules\karma\lib\config.js:342:22)
在新服务器上(C:\Path\to\my\Website\node\u modules\karma\lib\Server.js:56:20)
在Object.exports.run(C:\Path\to\my\Website\node\u modules\karma\lib\cli.js:280:7)
反对。(C:\Path\to\my\Website\node\u modules\karma\bin\karma:3:23)
在模块处编译(Module.js:570:32)

今天早上遇到了同样的问题,我发现更改ts节点版本解决了这个问题。我可以在不改变ts配置的情况下重现此问题-node@3.2.0,但整个构建在ts上运行良好-node@3.1.0,因此,这似乎是一个突破性的变化。

今天早上遇到了同样的问题,我发现更改ts节点版本解决了这个问题。我可以在不改变ts配置的情况下重现此问题-node@3.2.0,但整个构建在ts上运行良好-node@3.1.0,所以这似乎是一个突破性的变化。

无效配置文件通常指出文件的无效之处。输出中似乎缺少一些内容…@PWKad是否有任何输出的详细日志,因为这是我在控制台上的所有内容。无效配置文件通常指出该文件的无效之处。似乎输出中缺少了一些东西…@PWKad无论如何都有输出的详细日志,因为这就是我在控制台上的全部内容。