Skip to content

Commit 07bfb91

Browse files
committed
run with babel
1 parent 00c5b84 commit 07bfb91

File tree

8 files changed

+27
-16
lines changed

8 files changed

+27
-16
lines changed

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"mocha": "2.4.5"
2525
},
2626
"devDependencies": {
27+
"babel-core": "^6.5.2",
28+
"babel-polyfill": "^6.5.0",
2729
"chai": "^3.5.0",
2830
"chai-as-promised": "^5.2.0",
2931
"chai-spies": "^0.7.1"

src/create-runner.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ function createRunner(config, tests) {
1818
else {
1919
node = process.execPath;
2020
}
21-
var runnerOptions = setRunnerOptions(config);
21+
var runnerOptions = [];
2222
return spawn(node, [
2323
'/usr/local/bin/mocha',
2424
'--bail',
2525
'--harmony',
2626
("--reporter=" + path.join(__dirname, 'reporter'))
27-
].concat(runnerOptions).concat(tests), options);
27+
].concat(tests), options);
2828
}
2929
exports.createRunner = createRunner;
3030
function setRunnerOptions(config) {
@@ -34,7 +34,12 @@ function setRunnerOptions(config) {
3434
}
3535
if (config.testRunnerOptions.babel) {
3636
require('babel-core');
37-
runnerOptions.push('--compilers js:babel-core/register');
37+
var babelOptions = [
38+
'--use-strict',
39+
'--require babel-polyfill',
40+
'--compilers js:babel-core/register'
41+
];
42+
runnerOptions.concat(babelOptions);
3843
}
3944
return runnerOptions;
4045
}

test/babel.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ chai.use(chaiAsPromised);
55
var expect = chai.expect;
66

77
var getRunner = require('./utils/runner').getRunner;
8+
var getBabelRunner = require('./utils/babel-runner').getRunner;
89

910
describe('babel', function() {
1011

@@ -23,11 +24,11 @@ describe('babel', function() {
2324
return expect(run).to.eventually.deep.equal(expected);
2425
});
2526

26-
xit('should compile files before running tests', function() {
27+
it('should compile files before running tests', function() {
2728
var files = [
2829
['./babel-02.js']
2930
];
30-
var run = getRunner(files);
31+
var run = getBabelRunner(files);
3132
var expected = {
3233
pass: true,
3334
taskPosition: 1,

test/context/babel.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import 'babel-polyfill'
1+
"use strict";
2+
23
const a = 40;
34
let b = 2;
4-
var stringLit = `${a} + ${b} = ${a + b}`;
5+
var stringList = `${a} + ${b} = ${a + b}`;

test/loaders.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var expect = chai.expect;
66

77
var getRunner = require('./utils/runner').getRunner;
88

9-
xdescribe('loaders', function() {
9+
describe('loaders', function() {
1010

1111
describe('loadJS', function() {
1212
it('should load JS files', function() {

test/log.spec.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var expect = require('chai').expect;
2-
3-
describe('log', function () {
4-
5-
describe('double log', function () {});
6-
7-
});
1+
// var expect = require('chai').expect;
2+
//
3+
// describe('log', function () {
4+
//
5+
// describe('double log', function () {});
6+
//
7+
// });

test/tests/babel-01.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
"use strict";
22
var expect = require('chai').expect;
33

44
describe('babel-01', function () {

test/tests/babel-02.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
var expect = require('chai').expect;
2+
var loadContext = require('../utils/load-context').default;
3+
loadContext('./context/babel.js');
24

35
describe('babel-02', function () {
46

0 commit comments

Comments
 (0)