Skip to content

Commit e8f1be8

Browse files
author
Kent C. Dodds
committed
transpile tests 📚
1 parent 9cb7ab3 commit e8f1be8

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

‎package.json‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"prebuild": "rimraf dist",
88
"build": "babel --copy-files --out-dir dist --ignore *.test.js src",
9-
"test": "nyc mocha",
9+
"test": "cross-env NODE_ENV=test nyc mocha",
1010
"watch:test": "mocha --watch",
1111
"lint": "eslint src",
1212
"validate": "npm-run-all --parallel test lint build"
@@ -33,8 +33,11 @@
3333
},
3434
"devDependencies": {
3535
"babel-cli": "6.11.4",
36+
"babel-plugin-istanbul": "1.0.3",
3637
"babel-preset-es2015": "6.9.0",
38+
"babel-register": "6.11.6",
3739
"chai": "3.5.0",
40+
"cross-env": "2.0.0",
3841
"eslint": "3.2.0",
3942
"eslint-config-kentcdodds": "^9.0.0",
4043
"ghooks": "1.3.2",
@@ -56,12 +59,24 @@
5659
],
5760
"include": [
5861
"src"
62+
],
63+
"sourceMap": false,
64+
"instrument": false,
65+
"require": [
66+
"babel-register"
5967
]
6068
},
6169
"babel": {
6270
"presets": [
6371
"es2015"
64-
]
72+
],
73+
"env": {
74+
"test": {
75+
"plugins": [
76+
"istanbul"
77+
]
78+
}
79+
}
6580
},
6681
"config": {
6782
"ghooks": {

‎src/index.test.js‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
1-
'use strict';
1+
import {expect} from 'chai'
2+
import starWarsNames from '.'
23

3-
var expect = require('chai').expect;
4-
var starWarsNames = require('.');
4+
describe('starwars-names', () => {
5+
it('should have a list of all available names', () => {
6+
expect(starWarsNames.all).to.satisfy(isArrayOfStrings)
7+
})
58

6-
describe('starwars-names', function() {
7-
it('should have a list of all available names', function() {
8-
expect(starWarsNames.all).to.satisfy(isArrayOfStrings);
9-
});
10-
11-
it('should allow me to get a random name from the list', function() {
12-
expect(starWarsNames.random()).to.satisfy(isIncludedIn(starWarsNames.all));
13-
});
14-
});
9+
it('should allow me to get a random name from the list', () => {
10+
expect(starWarsNames.random()).to.satisfy(isIncludedIn(starWarsNames.all))
11+
})
12+
})
1513

1614
function isArrayOfStrings(array) {
17-
return array.every(function(i) {
18-
return typeof i === 'string';
19-
});
15+
return array.every(i => typeof i === 'string')
2016
}
2117

2218
function isIncludedIn(array) {
23-
return function(item) {
24-
return array.includes(item);
25-
};
19+
return item => array.includes(item)
2620
}

0 commit comments

Comments
 (0)