{"id":15364645,"url":"https://github.com/venables/mocha-line","last_synced_at":"2025-04-04T18:20:57.572Z","repository":{"id":57299871,"uuid":"123449207","full_name":"venables/mocha-line","owner":"venables","description":"Run mocha tests at a given line number","archived":false,"fork":false,"pushed_at":"2018-03-01T14:55:43.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T00:30:06.112Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/venables.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}},"created_at":"2018-03-01T14:54:55.000Z","updated_at":"2018-03-01T14:55:03.000Z","dependencies_parsed_at":"2022-09-01T13:10:36.098Z","dependency_job_id":null,"html_url":"https://github.com/venables/mocha-line","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venables%2Fmocha-line","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venables%2Fmocha-line/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venables%2Fmocha-line/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venables%2Fmocha-line/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/venables","download_url":"https://codeload.github.com/venables/mocha-line/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226262,"owners_count":20904476,"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-10-01T13:12:56.305Z","updated_at":"2025-04-04T18:20:57.546Z","avatar_url":"https://github.com/venables.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mocha-line\n\nRun mocha tests at a given line number.\n\n## Why?\n\nMocha is a solid test runner, but it does not support running tests at a given\nline number, instead opting for using a `--grep` matcher. This module aims to\naugment that behavior by converting a given line number to a `--grep` pattern.\n\n## Installation\n\n```\nyarn global add mocha-line\n```\n\n(Doesn't have to be `global`, but is easier this way)\n\n## Usage\n\n### Basic usage:\n\n```\n\u003e mocha-line ./test/controllers/users.spec.js:72\n\nUsersController.index\\(\\) returns a JSON list of users\n```\n\n### Usage with Mocha:\n\nMocha-line currently returns only the grep pattern, so this must be passed to\nmocha:\n\n```sh\nNODE_ENV=test ./node_modules/.bin/mocha ./test/controllers/users.spec.js --grep \"$( mocha-line ./test/controllers/users.spec.js:72 )\"\n```\n\nThis is a bit verbose and repetitive (something on the roadmap below), so it's\nuseful to map this to a script, like below in VSCode:\n\n### Usage in VSCode:\n\nTo use within VSCode, set up your tasks.json file to include the following task:\n\n```js\n{\n  // See https://go.microsoft.com/fwlink/?LinkId=733558\n  // for the documentation about the tasks.json format\n  \"version\": \"2.0.0\",\n  \"tasks\": [\n    {\n      \"label\": \"Run Test at Cursor (Mocha)\",\n      \"type\": \"shell\",\n      \"command\": \"NODE_ENV=test ./node_modules/.bin/mocha ${relativeFile} --grep \\\"$( mocha-line ${file}:${lineNumber} )\\\"\",\n      \"group\": \"test\",\n      \"presentation\": {\n          \"echo\": true,\n          \"reveal\": \"always\",\n          \"focus\": false,\n          \"panel\": \"new\"\n      }\n    }\n  ]\n}\n```\n\n## Roadmap\n\n- [x] Convert mocha test line numbers to basic grep pattern\n- [ ] Improve grep pattern by including all nested `describe`s\n- [ ] Spawn a mocha process directly from mocha-line (with mocha opts)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvenables%2Fmocha-line","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvenables%2Fmocha-line","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvenables%2Fmocha-line/lists"}