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

code coverage with babel istanbul #4649

Merged
merged 9 commits into from
Mar 22, 2022
7 changes: 7 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const babelConfig = {
plugins: [['babel-plugin-istanbul', {
extension: ['.js', '.vue']
}]]
};

module.exports = babelConfig;
24 changes: 12 additions & 12 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ if (coverageEnabled) {
module.exports = (config) => {
const webpackConfig = require('./webpack.dev.js');
delete webpackConfig.output;
if (coverageEnabled) {
trusktr marked this conversation as resolved.
Show resolved Hide resolved
webpackConfig.module.rules.push({
test: /\.js$/,
exclude: /node_modules|e2e|example|lib|dist|\.*.*Spec\.js/,
use: {
loader: 'istanbul-instrumenter-loader',
options: {
esModules: true
}
}
});
}
// if (coverageEnabled) {
// webpackConfig.module.rules.push({
// test: /\.js$/,
// exclude: /node_modules|e2e|example|lib|dist|\.*.*Spec\.js/,
// use: {
// loader: 'istanbul-instrumenter-loader',
// options: {
// esModules: true
// }
// }
// });
// }

config.set({
basePath: '',
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"@playwright/test": "1.19.2",
"allure-playwright": "2.0.0-beta.15",
"babel-eslint": "10.1.0",
"babel-loader": "^8.2.3",
trusktr marked this conversation as resolved.
Show resolved Hide resolved
"babel-plugin-istanbul": "^6.1.1",
"comma-separated-values": "3.6.4",
"copy-webpack-plugin": "10.2.0",
"core-js": "3.20.3",
Expand Down Expand Up @@ -66,6 +68,7 @@
"vue": "2.6.14",
"vue-eslint-parser": "8.2.0",
"vue-loader": "15.9.8",
"vue-template-babel-compiler": "^1.0.7",
"vue-template-compiler": "2.6.14",
"webpack": "5.68.0",
"webpack-cli": "4.9.2",
Expand Down
15 changes: 14 additions & 1 deletion webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,20 @@ const config = {
},
{
test: /\.vue$/,
use: 'vue-loader'
use: {
loader: 'vue-loader'
// Attempt to use Babel with babel-plugin-istanbul
// options: {
// compiler: require('vue-template-babel-compiler')
// }
}
},
// TODO this is added only for coverage, so move it to karma conf instead.
{
test: /\.js$/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.html$/,
Expand Down