wct-istanbul
=============================
A fork of web-component-tester-istanbul Istanbul coverage plugin for web-component-tester@^6.6.0 and @t2ym/web-component-tester.
Compatibility Table
| web-component-tester@^6.6.0 | @t2ym/web-component-tester@^6.0.2 |
---|
wct-istanbul | ^0.13.0 | ^0.12.4 - ^0.13.0 |
polymer-cli | ^1.7.0 | @t2ym/polymer-cli@^1.3.2 |
wct-browser-legacy | ✅ (*1) | ✅ (*1) |
browser.js | ✅ (*1) | t2ym/web-component-tester#^6.0.2 (*1) |
local browsers | ✅ | ✅ |
Sauce Labs | Small coverage only (*1) | ✅ (*1) |
import.meta | - (*2) | - (*2) |
Notes on Compatibility Table
(*1)
- Sauce Labs Compatibility
- Squid proxies in Sauce Labs do not pass large socket.io traffic data and thus drop large coverage data
wct-istanbul
+ @t2ym/web-component-tester@^6.0.2
support chopping and combining of large coverage data to pass the Sauce Labs proxies
- Make sure
browser.js
from @t2ym/web-component-tester@^6.0.2
or bower t2ym/web-component-tester#^6.0.2
is used
(*2)
- import.meta
Support
istanbul-lib-instrument@1.10.1
does not support import.meta
syntax- Workaround: Pre-instrumentation by
@babel/cli@^7.0.0-beta.46
with @babel/plugin-syntax-import-meta
and babel-plugin-istanbul
babel --plugins @babel/plugin-syntax-import-meta,babel-plugin-istanbul target.js
- Omit targets from
include
directive in wct.conf.json
Use this plugin to collect and report test coverage (via istanbul) for
your project on each test run.
Common Notes
- The same IstanbulJS libraries as nyc v11.0.3 are used since wct-istanbul 0.12.0.
- async/await support with IstanbulJS libraries
- Only global coverage thresholds are effective since wct-istanbul 0.12.0.
Installation
npm install --save-dev wct-istanbul
Notes on @t2ym/web-component-tester
npm install --save-dev @t2ym/web-component-tester
bower install --save-dev t2ym/web-component-tester
npm install -g @t2ym/polymer-cli
npm install -g wct-istanbul
Basic Usage
Add the following configuration to web-component-tester's config file.
Example
module.exports = {
plugins: {
istanbul: {
dir: "./coverage",
reporters: ["text-summary", "lcov"],
include: [
"**/*.js"
],
exclude: [
"/polymer/polymer.js",
"/platform/platform.js"
]
}
}
}
Options
Below are the available configuration options:
dir
The directory to write coverage reports to.
reporters
An array of istanbul reporters to use.
include
Files to include in instrumentation.
exclude
Files to exclude from instrumentation (this trumps files 'included' with
the option above).
Coverage Thresholds
In addition to measuring coverage, this plugin can be used to enforce
coverage thresholds. If coverage does not meet the configured thresholds,
then the test run will fail, even if all tests passed.
This requires specifying the thresholds
option for the plugin
Example
The following configuration will cause the test run to fail if less
than 100% of the statements in instrumented files are covered by
tests.
module.exports = {
plugins: {
istanbul: {
dir: "./coverage",
reporters: ["text-summary", "lcov"],
include: [
"**/*.js"
],
exclude: [
"/polymer/polymer.js",
"/platform/platform.js"
],
thresholds: {
global: {
statements: 100
}
}
}
}
}