Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
vite-plugin-istanbul
Advanced tools
vite-plugin-istanbul is a Vite plugin that integrates Istanbul for code coverage reporting. It allows you to instrument your code with Istanbul, which is useful for generating code coverage reports during testing.
Code Instrumentation
This feature allows you to instrument your code for coverage reporting. You can specify which files to include or exclude, the file extensions to consider, and whether to require an environment variable to enable instrumentation.
import { defineConfig } from 'vite';
import istanbul from 'vite-plugin-istanbul';
export default defineConfig({
plugins: [
istanbul({
include: 'src/*',
exclude: ['node_modules', 'test/'],
extension: ['.js', '.ts', '.vue'],
requireEnv: true,
}),
],
});
Custom Reporting
This feature allows you to customize the reporting options for Istanbul. You can specify the reporters to use and the directory where the reports should be saved.
import { defineConfig } from 'vite';
import istanbul from 'vite-plugin-istanbul';
export default defineConfig({
plugins: [
istanbul({
include: 'src/*',
exclude: ['node_modules', 'test/'],
extension: ['.js', '.ts', '.vue'],
requireEnv: true,
cypress: true,
nyc: {
reporter: ['html', 'text-summary'],
reportDir: './coverage',
},
}),
],
});
babel-plugin-istanbul is a Babel plugin for code coverage using Istanbul. It is similar to vite-plugin-istanbul but is used in Babel-based projects. It provides similar functionality for instrumenting code and generating coverage reports.
karma-coverage is a Karma plugin that uses Istanbul to generate code coverage reports. It is used in projects that use the Karma test runner and provides similar functionality for code instrumentation and reporting.
Jest is a JavaScript testing framework that has built-in support for code coverage using Istanbul. It provides a comprehensive testing solution with integrated code coverage reporting, making it a more all-in-one solution compared to 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.
Version v2.x for Vite v2.0, for Vite v1.0 install v1.x of this plugin.
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.
npm i -D vite-plugin-istanbul
or if you use yarn
yarn add -D vite-plugin-istanbul
import IstanbulPlugin from 'vite-plugin-istanbul';
Creates the vite plugin from a set of optional plugin options.
Returns: Vite Plugin
opts {IstanbulPluginOptions}
- Object of optional options to pass to the pluginopts.include {string|string[]}
- Optional string or array of strings of glob patterns to includeopts.exclude {string|string[]}
- Optional string or array of strings of glob patterns to excludeopts.extension {string|string[]}
- Optional string or array of strings of extensions to include (dot prefixed like .js or .ts)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 setopts.cypress {boolean}
- Optional boolean to change the env to CYPRESS_COVERAGE instead of VITE_COVERAGE. For more ease of use with @cypress/code-coverageTo use this plugin define it using vite.config.js
// vite.config.js
const istanbul = require('vite-plugin-istanbul');
module.exports = {
open: true,
port: 3000,
plugins: [
istanbul({
include: 'src/*',
exclude: ['node_modules', 'test/'],
extension: [ '.js', '.ts' ],
}),
],
};
FAQs
vite-plugin-istanbul ========================== [![Codacy grade](https://img.shields.io/codacy/grade/a0c628b128c044269faefc1da74382f7?style=for-the-badge&logo=codacy)](https://www.codacy.com/gh/iFaxity/vite-plugin-istanbul/dashboard) [![npm (scoped)](http
The npm package vite-plugin-istanbul receives a total of 172,143 weekly downloads. As such, vite-plugin-istanbul popularity was classified as popular.
We found that vite-plugin-istanbul demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.