{"id":23968763,"url":"https://github.com/rtvision/mocha-esbuild","last_synced_at":"2025-07-08T18:37:10.267Z","repository":{"id":143787609,"uuid":"429955809","full_name":"RTVision/mocha-esbuild","owner":"RTVision","description":"Run tests with mocha compiled by esbuild","archived":false,"fork":false,"pushed_at":"2021-11-29T21:08:53.000Z","size":601,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-29T10:01:57.213Z","etag":null,"topics":["esbuild","mocha","tests"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RTVision.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-19T22:58:00.000Z","updated_at":"2023-01-03T14:26:49.000Z","dependencies_parsed_at":"2023-06-17T18:47:55.973Z","dependency_job_id":null,"html_url":"https://github.com/RTVision/mocha-esbuild","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RTVision/mocha-esbuild","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTVision%2Fmocha-esbuild","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTVision%2Fmocha-esbuild/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTVision%2Fmocha-esbuild/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTVision%2Fmocha-esbuild/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RTVision","download_url":"https://codeload.github.com/RTVision/mocha-esbuild/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTVision%2Fmocha-esbuild/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264324674,"owners_count":23590934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esbuild","mocha","tests"],"created_at":"2025-01-07T00:46:23.875Z","updated_at":"2025-07-08T18:37:10.236Z","avatar_url":"https://github.com/RTVision.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mocha Esbuild\n=============\n[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)\n[![Version](https://img.shields.io/npm/v/@rtvision/mocha-esbuild.svg)](https://npmjs.org/package/@rtvision/mocha-esbuild)\n[![Downloads/week](https://img.shields.io/npm/dw/@rtvision/mocha-esbuild.svg)](https://npmjs.org/package/@rtvision/mocha-esbuild)\n[![License](https://img.shields.io/npm/l/@rtvision/mocha-esbuild.svg)](https://github.com/RtVision/mocha-esbuild/blob/master/package.json)\n\n\nRun tests with mocha compiled by esbuild at lightning fast [speeds](https://esbuild.github.io/). \n\nCLI requires a .esbuildrc.js file with an annotated example [here](https://github.com/RtVision/mocha-esbuild/blob/master/.esbuildrc.js)\nwhile its possible it would work only the defaults it really depends on your projects setup.\n\nI personally made this CLI to compile vue SFC components that are then tested with mocha and have seen pretty big speed increases.\nOne in partically that stood out to me was webpack building a single test file and all its dependencies took 1 minute and 15s while\nesbuild did it in about 15s. When developing tests this time saving really adds up!\n\nIf 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\nthe aliases like described [here](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping). You can use\nthis even if you don't have any typescript in your project since esbuild will look at your config file regardless.\n\nIf you want to use sourcemaps, you will need to either start mocha-esbuild with the node --enable-source-maps flag i.e.\n`node --enable-source-maps node_modules/@rtvision/bin/run -s --noImportSourceMapSupport` or do `npm install --save-dev source-map-support`.\n[Until node allows scripts to determine](https://github.com/nodejs/node/issues/38817) whether or not sources maps should be on this is only solution I know of.\nNote 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.\n\n\n# Install\n``` sh-session\nnpm i --save-dev @rtvision/mocha-esbuild\n```\n\n# Usage\n```sh-session\nnpx mocha-esbuild --help\nRun tests with mocha compiled by esbuild\n\nUSAGE\n  $ mocha-esbuild [FILE]\n\nARGUMENTS\n  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'\n\nOPTIONS\n  -b, --bail                         Bail on the first test failure.\n  -c, --color                        Color TTY output from reporter.\n  -g, --grep=grep                    Test filter given regular expression.\n  -h, --help                         show CLI help\n  -p, --parallel                     Run test in parallel.\n  -r, --require=require              Pathname of file that will be imported before tests run\n  -s, --sourcemaps                   Generates inline sourcemaps for easier debugging. Will overwrite sourcemaps if custom config provided\n  -t, --timeout=timeout              Timeout threshold value for mocha.\n  -v, --version                      show CLI version\n  -w, --watch                        Enable watch mode for esbuild. Will overwrite watch if custom config provided\n  --esbuildConfig=esbuildConfig      [default: .esbuildrc.js] Esbuild config file path. The follow options will always be overwritten: bundle, stdin/entryPoints, and outfile\n  --fgrep=fgrep                      Test filter given string\n  --fullTrace=fullTrace              Full stacktrace upon failure?\n  --invert                           Invert test filter matches?\n  --jobs=jobs                        Max number of worker processes for parallel runs\n  --mochaConfigPath=mochaConfigPath  Filepath to read mocha configs from, can be js or json file\n  --reporter=reporter                Reporter name to use\n  --retries=retries                  Number of times to retry failed tests\n```\n\n## License\nMIT © RtVision\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtvision%2Fmocha-esbuild","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtvision%2Fmocha-esbuild","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtvision%2Fmocha-esbuild/lists"}