Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@istanbuljs/nyc-config-typescript
Advanced tools
@istanbuljs/nyc-config-typescript is a configuration preset for the NYC code coverage tool, specifically tailored for TypeScript projects. It simplifies the setup process for collecting code coverage metrics in TypeScript applications by providing a pre-configured set of options that work out of the box.
Pre-configured NYC settings for TypeScript
This feature allows you to extend the default NYC configuration with settings optimized for TypeScript. By adding this to your `nyc` configuration in `package.json`, you can easily integrate code coverage into your TypeScript project.
{
"extends": "@istanbuljs/nyc-config-typescript"
}
Source map support
This configuration ensures that source maps are properly handled, allowing for accurate code coverage reports that map back to the original TypeScript source files. It includes all TypeScript files in the `src` directory and excludes declaration files.
{
"nyc": {
"extends": "@istanbuljs/nyc-config-typescript",
"all": true,
"check-coverage": true,
"reporter": ["html", "text-summary"],
"include": ["src/**/*.ts"],
"exclude": ["**/*.d.ts"]
}
}
ts-jest is a Jest transformer that allows you to use TypeScript with Jest. It provides a seamless integration for running tests written in TypeScript and generating code coverage reports. Unlike @istanbuljs/nyc-config-typescript, which is specific to NYC, ts-jest is tailored for Jest users.
babel-plugin-istanbul is a Babel plugin that instruments your code with Istanbul for code coverage. It works with any JavaScript project that uses Babel, including those that use TypeScript via Babel. This plugin is more flexible but requires a Babel setup, unlike @istanbuljs/nyc-config-typescript, which is a straightforward configuration preset.
Jest is a popular testing framework that includes built-in support for code coverage. It can be used with TypeScript through the ts-jest transformer. Jest provides an all-in-one solution for testing and code coverage, whereas @istanbuljs/nyc-config-typescript is focused solely on configuring NYC for TypeScript.
Handy default configuration for instrumenting your babel-backed project with test coverage using nyc.
First install the dependencies:
npm i nyc source-map-support ts-node @istanbuljs/nyc-config-typescript --save-dev
Then write a tsconfig.json
that looks something like this:
{
"sourceMap": "inline",
// OR
"sourceMap": true
}
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
}
If you're using mocha
:
--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": "nyc mocha"
}
ISC
FAQs
nyc configuration that works with typescript
The npm package @istanbuljs/nyc-config-typescript receives a total of 250,110 weekly downloads. As such, @istanbuljs/nyc-config-typescript popularity was classified as popular.
We found that @istanbuljs/nyc-config-typescript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.