Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/istanbuljs/esm-loader-hook
Loader hook for ESM instrumentation (experimental!!)
https://github.com/istanbuljs/esm-loader-hook
Last synced: 2 months ago
JSON representation
Loader hook for ESM instrumentation (experimental!!)
- Host: GitHub
- URL: https://github.com/istanbuljs/esm-loader-hook
- Owner: istanbuljs
- License: isc
- Created: 2020-03-17T13:43:48.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-06-13T12:48:47.000Z (over 1 year ago)
- Last Synced: 2024-11-08T05:44:18.609Z (3 months ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 11
- Watchers: 7
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @istanbuljs/esm-loader-hook
![Tests][tests-status]
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![ISC][license-image]](LICENSE)This [loader hook](https://nodejs.org/dist/latest/docs/api/esm.html#esm_hooks)
makes it relatively easy to use NYC to check coverage of ESM running in node.js
16.12.0. Note this makes use of **experimental** node.js features and thus may
stop working upon release of new versions of node.js. Until the node.js feature
is stabilized breakage should not be unexpected.For more stable options to test coverage you can:
* Use [c8]
* Pre-instrument your code (run `nyc instrument` then test the output)## Adding to processes
To install this hook into a process the module must be provided through the
`--experimental-loader` flag.The following can be used for your `npm test` script to enable live instrumentation
of ES modules being tested with mocha:```sh
cross-env 'NODE_OPTIONS=--experimental-loader @istanbuljs/esm-loader-hook' nyc mocha
```## Configuration
This module executes [babel-plugin-istanbul] in a loader hook. No
options are provided to the babel plugin and babel configuration files are not honored.
Normally configuration will be provided by the currently running instance of nyc. If
this module is run outside nyc then it will use `@istanbuljs/load-nyc-config` to load
options, defaults from `@istanbuljs/schema` will apply to missing options or if no
configuration is found.[tests-status]: https://github.com/cfware/node-preload/workflows/Tests/badge.svg
[npm-image]: https://img.shields.io/npm/v/@istanbuljs/esm-loader-hook.svg
[npm-url]: https://npmjs.org/package/@istanbuljs/esm-loader-hook
[downloads-image]: https://img.shields.io/npm/dm/@istanbuljs/esm-loader-hook.svg
[downloads-url]: https://npmjs.org/package/@istanbuljs/esm-loader-hook
[license-image]: https://img.shields.io/github/license/istanbuljs/esm-loader-hook[babel-plugin-istanbul]: https://github.com/istanbuljs/babel-plugin-istanbul#readme
[c8]: https://github.com/bcoe/c8#readme