Skip to content
This repository was archived by the owner on Jun 14, 2018. It is now read-only.

Commit ff9c817

Browse files
authored
Merge pull request vuejs-templates#402 from posva/master
Replace isparta with babel-plugin-istanbul
2 parents b0b52bb + 78510ac commit ff9c817

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

template/.babelrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"presets": ["es2015", "stage-2"],
33
"plugins": ["transform-runtime"],
4-
"comments": false
4+
"comments": false,
5+
"env": {
6+
"test": {
7+
"plugins": [ "istanbul" ]
8+
}
9+
}
510
}

template/build/webpack.base.conf.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ module.exports = {
4040
{
4141
test: /\.vue$/,
4242
loader: 'eslint',
43-
include: projectRoot,
43+
include: [
44+
path.join(projectRoot, 'src')
45+
],
4446
exclude: /node_modules/
4547
},
4648
{
4749
test: /\.js$/,
4850
loader: 'eslint',
49-
include: projectRoot,
51+
include: [
52+
path.join(projectRoot, 'src')
53+
],
5054
exclude: /node_modules/
5155
}
5256
],
@@ -59,7 +63,9 @@ module.exports = {
5963
{
6064
test: /\.js$/,
6165
loader: 'babel',
62-
include: projectRoot,
66+
include: [
67+
path.join(projectRoot, 'src')
68+
],
6369
exclude: /node_modules/
6470
},
6571
{

template/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"dev": "node build/dev-server.js",
99
"build": "node build/build.js"{{#unit}},
10-
"unit": "karma start test/unit/karma.conf.js --single-run"{{/unit}}{{#e2e}},
10+
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run"{{/unit}}{{#e2e}},
1111
"e2e": "node test/e2e/runner.js"{{/e2e}}{{#if_or unit e2e}},
1212
"test": "{{#unit}}npm run unit{{/unit}}{{#unit}}{{#e2e}} && {{/e2e}}{{/unit}}{{#e2e}}npm run e2e{{/e2e}}"{{/if_or}}{{#lint}},
1313
"lint": "eslint --ext .js,.vue src{{#unit}} test/unit/specs{{/unit}}{{#e2e}} test/e2e/specs{{/e2e}}"{{/lint}}
@@ -55,6 +55,7 @@
5555
"http-proxy-middleware": "^0.17.2",
5656
"json-loader": "^0.5.4",
5757
{{#unit}}
58+
"cross-env": "^3.1.3",
5859
"karma": "^1.3.0",
5960
"karma-coverage": "^1.1.1",
6061
"karma-mocha": "^1.2.0",
@@ -69,7 +70,7 @@
6970
"sinon": "^1.17.3",
7071
"sinon-chai": "^2.8.0",
7172
"inject-loader": "^2.0.1",
72-
"isparta-loader": "^2.0.0",
73+
"babel-plugin-istanbul": "^3.0.0",
7374
"phantomjs-prebuilt": "^2.1.3",
7475
{{/unit}}
7576
{{#e2e}}

template/test/unit/karma.conf.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var webpackConfig = merge(baseConfig, {
1818
devtool: '#inline-source-map',
1919
vue: {
2020
loaders: {
21-
js: 'isparta'
21+
js: 'babel-loader'
2222
}
2323
},
2424
plugins: [
@@ -31,18 +31,10 @@ var webpackConfig = merge(baseConfig, {
3131
// no need for app entry during tests
3232
delete webpackConfig.entry{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
3333

34-
// make sure isparta loader is applied before eslint
35-
webpackConfig.module.preLoaders = webpackConfig.module.preLoaders || []{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
36-
webpackConfig.module.preLoaders.unshift({
37-
test: /\.js$/,
38-
loader: 'isparta',
39-
include: path.resolve(projectRoot, 'src'){{#if_eq lintConfig "airbnb"}},{{/if_eq}}
40-
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
41-
42-
// only apply babel for test files when using isparta
34+
// Use babel for test files too
4335
webpackConfig.module.loaders.some(function (loader, i) {
44-
if (loader.loader === 'babel') {
45-
loader.include = path.resolve(projectRoot, 'test/unit'){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
36+
if (/^babel(-loader)?$/.test(loader.loader)) {
37+
loader.include.push(path.resolve(projectRoot, 'test/unit')){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
4638
return true{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
4739
}
4840
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}

0 commit comments

Comments
 (0)