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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ts-node-test

v0.4.4

Published

Use the Node.js test runner, but with TypeScript via ts-node

Downloads

7,553

Readme

ts-node-test

CI

Use the Node.js test runner, but with TypeScript via ts-node. You need to have typescript installed as a (dev) dependency and must be using Node version 18.7.0 or later.

Imagine it like ts-node --test, if that command existed.

Usage

Install as a dev dependency:

npm i -D ts-node-test

Then add a script to your package.json:

{
  "scripts": {
    "test": "ts-node-test test-file1.ts foo/test-file2.ts another-dir/"
  }
}

The command syntax is similar to node --test. Multiple paths can be passed. Directories will be searched recursively for any files with supported extensions (currently: .js, .mjs, .cjs; .ts, .mts, .cts). Then, Node's test runner will be started on all files that were found in this process.

Extensions

You can override the list of extensions by setting an environment variable (TEST_EXTENSIONS). This list will then be used instead of the default extensions. For example:

TEST_EXTENSIONS=.test.ts,.test.js ts-node-test test/

The above will recursively look for files in the test/ directory ending in .test.ts or .test.js.

CLI flags

The following additional CLI flags are supported, and will be passed along to Node.js when provided:

  • --test-name-pattern <pattern> *
  • --test-reporter <reporter> *
  • --test-reporter-destination <destination> *
  • --test-only
  • --watch
  • --watch-preserve-output
  • --experimental-test-coverage

Flags marked with * can be passed multiple times.

Why this is needed

TL;DR: Node.js (at the time of writing) does not allow to override the list of extensions that are used when searching for test files. The official recommendation is to list all files explicitly. That is precisely what this CLI wrapper does behind the scenes.

Please refer to the following issues for further information: