ReferenceError:未定义chai

时间:2017-04-11 03:00:33

标签: javascript typescript mocha karma-runner chai

我正在尝试使用mocha / chai / karma按照打字稿设计模式书进行测试。

但是我有这个错误:

> npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test"
> npm ERR! node v6.3.1 npm ERR! npm  v3.10.7 npm ERR! code ELIFECYCLE
> npm ERR! sample2@1.0.0 test: `mocha` npm ERR! Exit status 1 npm ERR!
> npm ERR! Failed at the sample2@1.0.0 test script 'mocha'. 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 sample2
> package, npm ERR! not with npm [![itself][1]][1]. npm ERR! Tell the author that
> this fails on your system: npm ERR!     mocha npm ERR! You can get
> information on how to open an issue for this project with: npm ERR!   
> npm bugs sample2 npm ERR! Or if that isn't available, you can get
> their info via: npm ERR!     npm owner ls sample2 npm ERR! There is
> likely additional logging output above.
> 
> npm ERR! Please include the following file with any support request:

我在这里缺少什么:

karma.conf.js

// Karma configuration
// Generated on Mon Apr 10 2017 21:43:48 GMT-0500 (COT)

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: ['mocha','chai'],


    // list of files / patterns to load in the browser
    files: [
      'test/mocha.js ',
      'out/*.js',
      'out/test/*.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
  })
}

的package.json

{
  "name": "sample2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha",
     "cover": "istanbul cover node_modules/mocha/bin/_mocha"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "chai": "^3.5.0",
    "karma": "^1.6.0",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-mocha": "^1.3.0",
    "mocha": "^3.2.0",
     "istanbul": "latest"
  }
}

mocha.js

chai.should();

我不认为任何其他文件是相关的

0 个答案:

没有答案