1. @istanbuljs/nyc-config-typescript
nyc configuration that works with typescript
@istanbuljs/nyc-config-typescript
Package: @istanbuljs/nyc-config-typescript
Created by: istanbuljs
Last modified: Tue, 05 Apr 2022 21:14:43 GMT
Version: 1.0.2
License: ISC
Downloads: 1,245,666
Repository: https://github.com/istanbuljs/istanbuljs

Install

npm install @istanbuljs/nyc-config-typescript
yarn add @istanbuljs/nyc-config-typescript

nyc-config-typescript

Handy default configuration for instrumenting your TypeScript-backed
project with test coverage using nyc.

First install the dependencies:

npm i -D nyc source-map-support ts-node @istanbuljs/nyc-config-typescript

Your tsconfig.json must be configured to produce source maps, either inline or as sibling files.

.nycrc

And write a .nycrc that looks like this:

 {
    "extends": "@istanbuljs/nyc-config-typescript",
    // OPTIONAL if you want coverage reported on every file, including those that aren't tested:
    "all": true
}

This package specifies the cache, exclude, and extension options for you - only override those if you absolutely must.
If you are going to modify include or exclude and you have specified a separate outDir in tsconfig.json, make sure that it remains included so that source mapping is possible.

Running Tests

If you're using mocha

In test/mocha.opts:

--require ts-node/register #replace with ts-node/register/transpile-only if you have custom types
--require source-map-support/register
--recursive
<glob for your test files>

Now setup the test scripts in your package.json like so (with the equivalent for your test runner):

 {
    "test": "tsc && nyc mocha"
}

If you're using Jasmine

In package.json:

 {
    "test": "tsc && nyc --require ts-node/register jasmine"
}

License

ISC

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin