vite-plugin-istanbul
Advanced tools
Comparing version 2.5.0 to 2.5.1
@@ -1,6 +0,6 @@ | ||
# [2.5.0](https://github.com/ifaxity/vite-plugin-istanbul/compare/v2.4.0...v2.5.0) (2022-02-09) | ||
## [2.5.1](https://github.com/ifaxity/vite-plugin-istanbul/compare/v2.5.0...v2.5.1) (2022-03-06) | ||
### Features | ||
### Bug Fixes | ||
* Support instrument in build mode ([90b7e8b](https://github.com/ifaxity/vite-plugin-istanbul/commit/90b7e8bab49dfaadef65c22e3949ce54f9d2668c)) | ||
* Docs for automatic sourcemapping ([21b7750](https://github.com/ifaxity/vite-plugin-istanbul/commit/21b77509330e8adf95643d3daa2b768a6a5bdd8d)) |
@@ -52,4 +52,6 @@ "use strict"; | ||
var _a; | ||
if (((_a = config.build) === null || _a === void 0 ? void 0 : _a.sourcemap) != true) { | ||
logger.warn(`${PLUGIN_NAME}> ${(0, chalk_1.yellow)('Sourcemaps not enabled and will be automatically enabled for code coverage to be accurate.')}`); | ||
// If sourcemap is not set (either undefined or false) | ||
if (!((_a = config.build) === null || _a === void 0 ? void 0 : _a.sourcemap)) { | ||
logger.warn(`${PLUGIN_NAME}> ${(0, chalk_1.yellow)(`Sourcemaps was automatically enabled for code coverage to be accurate. | ||
To hide this message set build.sourcemap to true, 'inline' or 'hidden'.`)}`); | ||
// Enforce sourcemapping, | ||
@@ -78,2 +80,3 @@ config.build = config.build || {}; | ||
// Returns the current code coverage in the global scope | ||
// Used if an external endpoint is required to fetch code coverage | ||
middlewares.use((req, res, next) => { | ||
@@ -80,0 +83,0 @@ var _a; |
{ | ||
"name": "vite-plugin-istanbul", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"author": "iFaxity (christian@faxity.se)", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
vite-plugin-istanbul | ||
========================== | ||
[](https://app.codacy.com/manual/iFaxity/vite-plugin-istanbul/dashboard) | ||
[](https://www.codacy.com/gh/iFaxity/vite-plugin-istanbul/dashboard?utm_source=github.com&utm_medium=referral&utm_content=iFaxity/vite-plugin-istanbul&utm_campaign=Badge_Grade) | ||
[](https://npmjs.org/package/vite-plugin-istanbul) | ||
@@ -9,8 +9,7 @@ [](https://npmjs.org/package/vite-plugin-istanbul) | ||
A Vite plugin to instrument your code for nyc/istanbul code coverage. In similar way as the Webpack Loader istanbul-instrumenter-loader. Only intended for use in development while running tests. | ||
A Vite plugin to instrument your code for nyc/istanbul code coverage. In similar way as the Webpack Loader `istanbul-instrumenter-loader`. Only intended for use in development while running tests. | ||
Version v2.x for Vite v2.0, for Vite v1.0 install v1.x of this plugin. | ||
However only the v2 version is actively tested and developed. | ||
As of v2.1.0 you can toggle the coverage off by setting the env variable `VITE_COVERAGE='false'`, by default it will always instrument the code. To require the explicit definition of the variable, set the option `requireEnv` to **true**. | ||
Installation | ||
@@ -38,12 +37,21 @@ -------------------------- | ||
#### Parameters | ||
* `opts {IstanbulPluginOptions}` - Object of optional options to pass to the plugin. | ||
* `opts.cwd {string}` - Optional string of the current working directory, used for the include/exclude patterns. Defaults to process.cwd(). | ||
* `opts.include {string|string[]}` - Optional string or array of strings of glob patterns to include. | ||
* `opts.exclude {string|string[]}` - Optional string or array of strings of glob patterns to exclude. | ||
* `opts.extension {string|string[]}` - Optional string or array of strings of extensions to include (dot prefixed like .js or .ts). By default this is set to `['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue']`. | ||
* `opts.requireEnv {boolean}` - Optional boolean to require env to be true to instrument to code, otherwise it will instrument even if env variable is not set. | ||
* `opts.cypress {boolean}` - Optional boolean to change the env to CYPRESS_COVERAGE instead of VITE_COVERAGE. For ease of use with @cypress/code-coverage. | ||
* `opts.checkProd {boolean}` - Optional boolean to enforce the plugin to skip instrumentation for production environments, checks *NODE_ENV* for "production" (case insensitive). Defaults to true. | ||
* `opts.forceBuildInstrument {boolean}` - Optional boolean to enforce the plugin to add instrumentation in build mode. Defaults to false. | ||
* `opts {IstanbulPluginOptions}` - Object of optional options to pass to the plugin. | ||
* `opts.cwd {string}` - Optional string of the current working directory, used for the include/exclude patterns. Defaults to `process.cwd()`. | ||
* `opts.include {string|string[]}` - Optional string or array of strings of glob patterns to include. | ||
* `opts.exclude {string|string[]}` - Optional string or array of strings of glob patterns to exclude. | ||
* `opts.extension {string|string[]}` - Optional string or array of strings of extensions to include (dot prefixed like .js or .ts). By default this is set to `['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue']`. | ||
* `opts.requireEnv {boolean}` - Optional boolean to require the environment variable (defaults to **VITE_COVERAGE**) to equal `true` in order to instrument the code. Otherwise it will instrument even if env variable is not set. However if `requireEnv` is not set the instrumentation will stop if the environment variable is equal to `false`. | ||
* `opts.cypress {boolean}` - Optional boolean to change the environment variable to **CYPRESS_COVERAGE** instead of **VITE_COVERAGE**. For ease of use with `@cypress/code-coverage``. | ||
* `opts.checkProd {boolean}` - Optional boolean to enforce the plugin to skip instrumentation for production environments. Looks at Vite's **isProduction** key from the `ResolvedConfig`. | ||
* `opts.forceBuildInstrument {boolean}` - Optional boolean to enforce the plugin to add instrumentation in build mode. Defaults to false. | ||
Notes | ||
-------------------------- | ||
As of v2.1.0 you can toggle the coverage off by setting the env variable `VITE_COVERAGE='false'`, by default it will always instrument the code. To require the explicit definition of the variable, set the option `requireEnv` to **true**. | ||
This plugin also requires the Vite configuration [build.sourcemap](https://vitejs.dev/config/#build-sourcemap) to be set to either **true**, **'inline'**, **'hidden'**. | ||
But the plugin will automatically default to **true** if it is missing in order to give accurate cove coverage. | ||
The plugin will notify when this happens in order for a developer to fix it. This notification will show even when the plugin is disabled by e.g `opts.requireEnv`, `VITE_COVERAGE=false`. This is due to a limitation of the API for this kind of feature. | ||
Examples | ||
@@ -50,0 +58,0 @@ -------------------------- |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
16452
129
82