npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@appngo-sk/mocha-chai

v1.0.5

Published

Dependencies for testing typescript modules.

Downloads

30

Readme

Mocha - Chai

Dependencies for testing typescript modules.

Installation

Install with npm

npm install --save-dev @appngo-sk/mocha-chai

or with yarn

yarn add -D @appngo-sk/mocha-chai

Run script

nyc mocha --checkLeaks \
    -r tsconfig-paths/register \
    -r ts-node/register \
    -r source-map-support/register \
    "test/**/*.test.ts"

Configuration

Create a configuration file .nycrc for nyc package inside of the project root directory with any of following extensions

| File name | File association | | --------------- | ---------------- | | .nycrc | JSON | | .nycrc.json | JSON | | .nycrc.yaml | YAML | | .nycrc.yml | YAML | | nyc.config.js | CommonJS export |

The content of the file should extend this module.

{
  "extends": "@appngo-sk/mocha-chai"
}

Dependencies

{
  "@istanbuljs/nyc-config-typescript": "^1.0.1",
  "@types/chai": "^4.2.22",
  "@types/mocha": "^9.0.0",
  "@types/node": "^16.11.7",
  "chai": "^4.3.4",
  "mocha": "^9.1.3",
  "nyc": "^15.1.0",
  "source-map-support": "^0.5.20",
  "ts-node": "^10.4.0",
  "tsconfig-paths": "^3.11.0",
  "typescript": "^4.4.4"
}

Typescript


TypeScript is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript.

Mocha


Simple, flexible, fun JavaScript test framework for Node.js & The Browser.

Used to run tests

{
  "scripts": {
    "test": "mocha"
  }
}

Types

Used with Typescript.

Chai


Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.

Types

Used with typescript.

nyc


JavaScript test coverage made simple. Istanbul's state of the art command line interface.

{
  "scripts": {
    "test": "mocha",
    "coverage": "nyc npm run test"
  }
}

Configuring nyc

The main export is a configuration json file for nyc.

{
  "extends": "@istanbuljs/nyc-config-typescript",
  "all": true,
  "check-coverage": true,
  "reporter": [
    "text",
    "html"
  ]
}
TypeScript projects

Please start with the pre-configured @istanbuljs/nyc-config-typescript preset.

Configuration options

| Option name | Description | Value | Default | | ---------------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | | all | Whether or not to instrument all files (not just the ones touched by your test suite) | true | false | | check-coverage | Check whether coverage is within thresholds, fail if not | true | false | | reporter | Coverage reporters to use | text, html | text |

nyc config typescript


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

.nycrc

{
  "extends": "@istanbuljs/nyc-config-typescript"
}

Source map support


This module provides source map support for stack traces in node via the V8 stack trace API. It uses the source-map module to replace the paths and line numbers of source-mapped files with their original paths and line numbers. The output mimics node's stack trace format with the goal of making every compile-to-JS language more of a first-class citizen. Source maps are completely general (not specific to any one language) so you can use source maps with multiple compile-to-JS languages in the same node process.

ts-node


ts-node is a TypeScript execution engine and REPL for Node.js.

It JIT transforms TypeScript into JavaScript, enabling you to directly execute TypeScript on Node.js without precompiling. This is accomplished by hooking node's module loading APIs, enabling it to be used seamlessly alongside other Node.js tools and libraries.

Use with mocha

mocha -r ts-node/register

Types

Types for node.

tsconfig-paths


Use this to load modules whose location is specified in the paths section of tsconfig.json. Both loading at run-time and via API are supported.

Typescript by default mimics the Node.js runtime resolution strategy of modules. But it also allows the use of path mapping, which allows arbitrary module paths (that doesn't start with "/" or ".") to be specified and mapped to physical paths in the filesystem. The typescript compiler can resolve these paths from tsconfig so it will compile OK. But if you then try to execute the compiled files with node (or ts-node), it will only look in the node_modules folders all the way up to the root of the filesystem and thus will not find the modules specified by paths in tsconfig.

If you require this package's tsconfig-paths/register module it will read the paths from tsconfig.json and convert node's module loading calls into to physical file paths that node can load.

Use with mocha and ts-node

You also have to specify a glob that includes .ts files because mocha looks after files with .js extension by default.

mocha -r ts-node/register -r tsconfig-paths/register "test/**/*.ts"