Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace isparta with babel-plugin-istanbul #402

Merged
merged 1 commit into from
Dec 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion template/.babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime"],
"comments": false
"comments": false,
"env": {
"test": {
"plugins": [ "istanbul" ]
}
}
}
12 changes: 9 additions & 3 deletions template/build/webpack.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ module.exports = {
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
include: [
path.join(projectRoot, 'src')
],
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
include: [
path.join(projectRoot, 'src')
],
exclude: /node_modules/
}
],
Expand All @@ -59,7 +63,9 @@ module.exports = {
{
test: /\.js$/,
loader: 'babel',
include: projectRoot,
include: [
path.join(projectRoot, 'src')
],
exclude: /node_modules/
},
{
Expand Down
5 changes: 3 additions & 2 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"dev": "node build/dev-server.js",
"build": "node build/build.js"{{#unit}},
"unit": "karma start test/unit/karma.conf.js --single-run"{{/unit}}{{#e2e}},
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run"{{/unit}}{{#e2e}},
"e2e": "node test/e2e/runner.js"{{/e2e}}{{#if_or unit e2e}},
"test": "{{#unit}}npm run unit{{/unit}}{{#unit}}{{#e2e}} && {{/e2e}}{{/unit}}{{#e2e}}npm run e2e{{/e2e}}"{{/if_or}}{{#lint}},
"lint": "eslint --ext .js,.vue src{{#unit}} test/unit/specs{{/unit}}{{#e2e}} test/e2e/specs{{/e2e}}"{{/lint}}
Expand Down Expand Up @@ -54,6 +54,7 @@
"http-proxy-middleware": "^0.17.2",
"json-loader": "^0.5.4",
{{#unit}}
"cross-env": "^3.1.3",
"karma": "^1.3.0",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.2.0",
Expand All @@ -68,7 +69,7 @@
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"inject-loader": "^2.0.1",
"isparta-loader": "^2.0.0",
"babel-plugin-istanbul": "^3.0.0",
"phantomjs-prebuilt": "^2.1.3",
{{/unit}}
{{#e2e}}
Expand Down
16 changes: 4 additions & 12 deletions template/test/unit/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var webpackConfig = merge(baseConfig, {
devtool: '#inline-source-map',
vue: {
loaders: {
js: 'isparta'
js: 'babel-loader'
}
},
plugins: [
Expand All @@ -31,18 +31,10 @@ var webpackConfig = merge(baseConfig, {
// no need for app entry during tests
delete webpackConfig.entry{{#if_eq lintConfig "airbnb"}};{{/if_eq}}

// make sure isparta loader is applied before eslint
webpackConfig.module.preLoaders = webpackConfig.module.preLoaders || []{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
webpackConfig.module.preLoaders.unshift({
test: /\.js$/,
loader: 'isparta',
include: path.resolve(projectRoot, 'src'){{#if_eq lintConfig "airbnb"}},{{/if_eq}}
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}

// only apply babel for test files when using isparta
// Use babel for test files too
webpackConfig.module.loaders.some(function (loader, i) {
if (loader.loader === 'babel') {
loader.include = path.resolve(projectRoot, 'test/unit'){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
if (/^babel(-loader)?$/.test(loader.loader)) {
loader.include.push(path.resolve(projectRoot, 'test/unit')){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
return true{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
}
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
Expand Down