Giter VIP home page Giter VIP logo

esbuild-plugin-istanbul's Introduction

esbuild-plugin-istanbul

An esbuild loader that instruments code with istanbul/nyc.

Usage

import { esbuildPluginIstanbul } from "esbuild-plugin-istanbul";

const jsPlugin = esbuildPluginIstanbul({
  filter: /\.[cm]?js$/,
  loader: "js",
  name: "istanbul-loader-js",
});

const jsxPlugin = esbuildPluginIstanbul({
  filter: /\.jsx$/,
  loader: "jsx",
  name: "istanbul-loader-jsx",
});

const tsPlugin = esbuildPluginIstanbul({
  filter: /\.[cm]?ts$/,
  loader: "ts",
  name: "istanbul-loader-ts",
});

const tsxPlugin = esbuildPluginIstanbul({
  filter: /\.tsx$/,
  loader: "tsx",
  name: "istanbul-loader-tsx",
});

await esbuild.build({
  plugins: [jsPlugin, jsxPlugin, tsPlugin, tsxPlugin],
});

esbuild-plugin-istanbul's People

Watchers

 avatar

esbuild-plugin-istanbul's Issues

Request for assistance to get `esbuild-plugin-istanbul` working

Hi @abraha2d,

Description

I've been trying to use your package in an Angular 17 app which uses vite+esbuild but haven't been successful yet.

You can view the sample app app /demos/code-coverage-with-istanbul-via-esbuild-plugin. It's part of the code-coverage-esbuild branch.

What I've done so far

  1. Created an Angular 17 app

  2. Used the @angular-builders/custom-esbuild to allow me to customize Angular's ESBuild configuration. This allowed me to specify files to be executed as ESBuild plugins

  3. Added a couple of ESBuild plugin files:

    • code-coverage-3.ts: this file contains a simple plugin I coded to log to the console the ESBuild plugins that are configured for this app. I was using this just for debug purposes.
    • code-coverage-4.ts: this file is using your esbuild-plugin-istanbul package to instrument .ts files with Istanbul.

How to run

  1. Clone the code-coverage-esbuild branch.
  2. Go to /demos/code-coverage-with-istanbul-via-esbuild-plugin
  3. Run npm i to install the npm packages.
  4. Run npm start to run the app.

How I checked that code coverage isn't being collected

  1. After starting the app, go to http://localhost:4200/
  2. Check for code coverage instrumentaton by going to the dev tools and on the console executing: window.__coverage__.
  3. Note how window.__coverage__ is undefined.

Note

If you follow the steps for the How to run and How I checked that code coverage isn't being collected for the app at /demos/code-coverage-with-istanbul-via-webpack-babel-plugin then window.__coverage__ won't be undefined.

The app at /demos/code-coverage-with-istanbul-via-webpack-babel-plugin is also an Angular 17 app but is using webpack instead of esbuild and for the instrumentation it uses the babel-plugin-istanbul npm package.

Help

Could you provide any guidance on how to use your package to instrument the sample Angular 17 app I linked ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.