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

@rtvision/mocha-esbuild

v0.1.8

Published

Run tests with mocha compiled by esbuild

Downloads

28

Readme

Mocha Esbuild

oclif Version Downloads/week License

Run tests with mocha compiled by esbuild at lightning fast speeds.

CLI requires a .esbuildrc.js file with an annotated example here while its possible it would work only the defaults it really depends on your projects setup.

I personally made this CLI to compile vue SFC components that are then tested with mocha and have seen pretty big speed increases. One in partically that stood out to me was webpack building a single test file and all its dependencies took 1 minute and 15s while esbuild did it in about 15s. When developing tests this time saving really adds up!

If you need alias's to work like webpacks common @ resolving to ./src then you can add a tsconfig.json or a jsconfig.json file and add the aliases like described here. You can use this even if you don't have any typescript in your project since esbuild will look at your config file regardless.

If you want to use sourcemaps, you will need to either start mocha-esbuild with the node --enable-source-maps flag i.e. node --enable-source-maps node_modules/@rtvision/bin/run -s --noImportSourceMapSupport or do npm install --save-dev source-map-support. Until node allows scripts to determine whether or not sources maps should be on this is only solution I know of. Note that this does introduce some big overhead for bigger files/projects, I myself notice several seconds of slowdown in startup time of the tests. I only enable it while developing tests or rerunning a failed test locally.

Install

npm i --save-dev @rtvision/mocha-esbuild

Usage

npx mocha-esbuild --help
Run tests with mocha compiled by esbuild

USAGE
  $ mocha-esbuild [FILE]

ARGUMENTS
  FILE  [default: test/unit/**/*.spec.js] File path to the entry point to build from. Can be 1 specific file or take a globstar such as 'test/unit/**/*.spec.js'

OPTIONS
  -b, --bail                         Bail on the first test failure.
  -c, --color                        Color TTY output from reporter.
  -g, --grep=grep                    Test filter given regular expression.
  -h, --help                         show CLI help
  -p, --parallel                     Run test in parallel.
  -r, --require=require              Pathname of file that will be imported before tests run
  -s, --sourcemaps                   Generates inline sourcemaps for easier debugging. Will overwrite sourcemaps if custom config provided
  -t, --timeout=timeout              Timeout threshold value for mocha.
  -v, --version                      show CLI version
  -w, --watch                        Enable watch mode for esbuild. Will overwrite watch if custom config provided
  --esbuildConfig=esbuildConfig      [default: .esbuildrc.js] Esbuild config file path. The follow options will always be overwritten: bundle, stdin/entryPoints, and outfile
  --fgrep=fgrep                      Test filter given string
  --fullTrace=fullTrace              Full stacktrace upon failure?
  --invert                           Invert test filter matches?
  --jobs=jobs                        Max number of worker processes for parallel runs
  --mochaConfigPath=mochaConfigPath  Filepath to read mocha configs from, can be js or json file
  --reporter=reporter                Reporter name to use
  --retries=retries                  Number of times to retry failed tests

License

MIT © RtVision