码迷,mamicode.com
首页 > 其他好文 > 详细

Writing Jasmine Unit Tests In ES6

时间:2018-07-03 18:16:55      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:ack   RoCE   server   serve   com   set   www.   dep   sts   

1. package.json

{
  "scripts": {
    "tests": "karma start"
  },
  "devDependencies": {
    "babel-loader": "^7.1.4",
    "webpack": "^4.12.0",
    "jasmine-core": "^3.1.0",
    "karma": "^2.0.4",
    "karma-jasmine": "^1.1.2",
    "jasmine": "^3.1.0",
    "karma-phantomjs-launcher": "^1.0.4",
    "karma-webpack": "^3.0.0"
  }
}

2. karma.config.js

module.exports = function(config) {
    config.set({
        browsers: [‘PhantomJS‘],
        files: [
            { pattern: ‘test-context.js‘, watched: false }
        ],
        frameworks: [‘jasmine‘],
        preprocessors: {
            ‘test-context.js‘: [‘webpack‘]
        },
        webpack: {
            module: {
                loaders: [
                    { test: /\.js/, exclude: /node_modules/, loader: ‘babel-loader‘ }
                ]
            },
            watch: true
        },
        webpackServer: {
            noInfo: true
        }
    });
};

 

3. test-context.js

var context = require.context(‘./spec‘, true, /.spec\.js$/);
context.keys().forEach(context);

 

Reference:

http://www.syntaxsuccess.com/viewarticle/writing-jasmine-unit-tests-in-es6

 

Writing Jasmine Unit Tests In ES6

标签:ack   RoCE   server   serve   com   set   www.   dep   sts   

原文地址:https://www.cnblogs.com/xiaobin-hlj80/p/9259678.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!