-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
code coverage with babel istanbul (#4649)
* WIP add instanbul code coverage to vue files * move webpack coverage config to a separate file for test:coverage, pin dependencies, remove istanbul-instrumenter-loader * dont include node_modules in babel config, it breaks istanbul for some reason * ignore spec files from coverage * document coverage files, remove unused karma config * use test instead of test:coverage in config.yml, disable code and link to issue to enable coverage in Vue <template>s
- Loading branch information
Showing
6 changed files
with
60 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
loglevel=warn | ||
|
||
# Temporary: istanbul-instrumenter-loader is working with webpack 5, but states | ||
# webpack 4 being the latest version it supports, so this legacy-peer-deps | ||
# allows us to install it anyway. | ||
legacy-peer-deps=true | ||
|
||
#Prevent folks from ignoring an important error when building from source | ||
engine-strict=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// This is a Babel config that webpack.coverage.js uses in order to instrument | ||
// code with coverage instrumentation. | ||
const babelConfig = { | ||
plugins: [['babel-plugin-istanbul', { | ||
extension: ['.js', '.vue'] | ||
}]] | ||
}; | ||
|
||
module.exports = babelConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// This file extends the webpack.dev.js config to add istanbul coverage | ||
// instrumentation using babel-plugin-istanbul (see babel.coverage.js) | ||
|
||
const config = require('./webpack.dev'); | ||
|
||
const path = require('path'); | ||
|
||
config.devtool = false; | ||
|
||
const vueLoaderRule = config.module.rules.find(r => r.use === 'vue-loader'); | ||
|
||
vueLoaderRule.use = { | ||
loader: 'vue-loader' | ||
// Attempt to use Babel with babel-plugin-istanbul | ||
|
||
// TODO The purpose of this was to try to add coverage to JS expressions | ||
// inside `<template>` markup, but it seems to add only coverage inside | ||
// `<script>` tags. | ||
// Issue: https://github.com/nasa/openmct/issues/4973 | ||
// | ||
// options: { | ||
// compiler: require('vue-template-babel-compiler'), | ||
// compilerOptions: { | ||
// babelOptions: require('./babel.coverage') | ||
// } | ||
// } | ||
}; | ||
|
||
config.module.rules.push({ | ||
test: /\.js$/, | ||
// test: /(\.js$)|(\?vue&type=template)/, | ||
// exclude: /node_modules(?!.*\.vue)/, | ||
exclude: /(Spec\.js$)|(node_modules)/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
configFile: path.resolve(process.cwd(), 'babel.coverage.js') | ||
} | ||
} | ||
}); | ||
|
||
module.exports = config; |