{"id":20358828,"url":"https://github.com/coderline/mocha-vscode","last_synced_at":"2025-04-12T03:22:34.410Z","repository":{"id":230725049,"uuid":"776928410","full_name":"CoderLine/mocha-vscode","owner":"CoderLine","description":"A Mocha test runner extension for VS Code","archived":false,"fork":false,"pushed_at":"2024-04-22T09:24:04.000Z","size":1167,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-28T06:17:33.613Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CoderLine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"code-of-conduct.md","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":"2024-03-24T20:29:32.000Z","updated_at":"2024-04-29T10:39:28.343Z","dependencies_parsed_at":"2024-04-29T10:51:06.458Z","dependency_job_id":null,"html_url":"https://github.com/CoderLine/mocha-vscode","commit_stats":null,"previous_names":["danielku15/mocha-vscode","coderline/mocha-vscode"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderLine%2Fmocha-vscode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderLine%2Fmocha-vscode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderLine%2Fmocha-vscode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderLine%2Fmocha-vscode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CoderLine","download_url":"https://codeload.github.com/CoderLine/mocha-vscode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248510600,"owners_count":21116233,"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":[],"created_at":"2024-11-14T23:29:03.436Z","updated_at":"2025-04-12T03:22:34.389Z","avatar_url":"https://github.com/CoderLine.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mocha VS Code Extension\n\nThis a community Visual Studio Code extension for enabling developers to run and debug [Mocha](https://mochajs.org/) tests right within VS Code using the built-in test explorer.\n\n\u003e [!NOTE]\n\u003e This extension is in a fairly early development stage but mostly functional. But watch out for any bugs 😉 \n\u003e \n\u003e Please provide feedback and discuss improvements over at https://github.com/CoderLine/mocha-vscode/discussions and https://github.com/CoderLine/mocha-vscode/issues\n\n## Getting Started\n\nTo get started follow the [general Mocha documentation](https://mochajs.org/) to set up testing for your project using the Mocha command line. Then, [install this extension](https://marketplace.visualstudio.com/items?itemName=coderline.mocha-vscode).\n\nThis extension automatically discovers and works with the `.mocharc.js/cjs/yaml/yml/json/jsonc` files found in your workspace. It requires minimal to no extra configuration. It works by looking at test files in your JavaScript and TypeScript code.\n\n## Configuration\n\n- `mocha-vscode.extractSettings`: Configures how tests get extracted. You can configure:\n\n  - The `extractWith` mode, that specifies if tests are extracted.\n    - `evaluation-cjs` (default) Translate the test file to CommonJS and evaluate it with all dependencies mocked.\n    - `evaluation-cjs-full` Translate the test file to CommonJS and fully evaluate it with all dependencies.\n    - `syntax` Parse the file and try to extract the tests from the syntax tree.\n  - The `extractTimeout` limiting how long the extraction of tests for a single file is allowed to take.\n  - The `test` and `suite` identifiers the process extracts. Defaults to `[\"it\", \"test\"]` and `[\"describe\", \"suite\"]` respectively, covering Mocha's common interfaces.\n  - The `hooks` identifiers to avoid Mocha executing stuff on test discovery. Defaults to `[\"before\", \"after\", \"beforeEach\", \"afterEach\"]`.\n\n- `mocha-vscode.debugOptions`: options, normally found in the launch.json, to pass when debugging the extension. See [the docs](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_launch-configuration-attributes) for a complete list of options.\n\n- `mocha-vscode.env`: Additional environment variables set when executing tests. This is useful for setting things like `NODE_ENV`.\n\n## Features\n\n### Show, Running and Debugging Tests\n\nThis plugin integrates with the built-in test explorer and editor of VS Code to show, run and debug tests.\n\nThe extension detects `.mocharc.\u003cextension\u003e` configuration files in any folder or workspace you open and will use it to discover the tests to be run.\n\n![Show Run Debug](resources/show-run-debug.png)\n\n### TypeScript and ESM integration\n\nThis extension is designed to work with both TypeScript, JavaScript (CJS/ESM) codebases assuming you already have a working setup with Mocha and TypeScript integrated.\n\nTo discover tests this extension dynamically translates your TypeScript or ESM code to CommonJS code (via [ESBuild](https://esbuild.github.io/)) and executes it partially to build up the test list. If this execution fails or you are having code which cannot be translated to CommonJS (e.g. top level awaits) this will result in errors. \n\nFor execution this extension will try to call directly the Mocha executable passing the `.mocharc` and additional arguments to it. \n\n## Troubleshooting\n\n### Check if Mocha itself works\n\nIf you face any issues the first step should be to check whether your tests are working with Mocha itself (outside this extension). Use `npx mocha` in your working and test directories to see whether tests are found and executed successfully. In this case you might [reach out to the Mocha folks](https://github.com/mochajs/mocha/blob/master/.github/CONTRIBUTING.md) to ask questions or report bugs.\n\n### Check the output window\n\nThis extension creates a new output log channel where we print whats happening behind the scenes. You can also increase the log level in VS Code via the `Developer: Set Log Level...` command.\n\n![Output Window](resources/output.png)\n\n![Set Log Level](resources/set-log-level.png)\n\n\n## Credits\n\nThis project started as a fork of the `Extension Test Runner` and `Command-line runner for VS Code tests` developed by Microsoft and then was adapted to work with Mocha directly.\nThe main credits of this extension go over to the folks at Microsoft (and their contributors) and without them it would have been a lot more effort to ship a Mocha test runner for VS Code.\n\n- https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner\n- https://github.com/microsoft/vscode-extension-test-runner\n- https://github.com/microsoft/vscode-test-cl\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderline%2Fmocha-vscode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderline%2Fmocha-vscode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderline%2Fmocha-vscode/lists"}