Socket
Socket
Sign inDemoInstall

vite-plugin-istanbul

Package Overview
Dependencies
0
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-istanbul


Version published
Maintainers
1
Created

Package description

What is vite-plugin-istanbul?

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.

What are vite-plugin-istanbul's main functionalities?

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',
      },
    }),
  ],
});

Other packages similar to vite-plugin-istanbul

Readme

Source

vite-plugin-istanbul

Codacy grade npm (scoped) npm bundle size (scoped) npm bundle size (scoped)

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.

Installation

$ npm i -D vite-plugin-istanbul

or if you use yarn

$ yarn add -D vite-plugin-istanbul

API

import IstanbulPlugin from 'vite-plugin-istanbul';

IstanbulPlugin( [ opts ] )

Creates the vite plugin from a set of optional plugin options.

Returns: Vite Plugin

Parameters
  • opts {IstanbulPluginOptions} - Object of optional options to pass to the plugin
  • 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)

Examples

To 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' ],
    }),
  ],
};

Testing (TODO: not yet finished)

$ npm run test

License

MIT

Keywords

FAQs

Last updated on 12 Aug 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc