{"id":15552309,"url":"https://github.com/bahmutov/changed-test-ids","last_synced_at":"2026-03-04T17:31:10.497Z","repository":{"id":193589591,"uuid":"689116161","full_name":"bahmutov/changed-test-ids","owner":"bahmutov","description":"Select tests to run based on source file changes and test ids","archived":false,"fork":false,"pushed_at":"2025-11-20T19:09:43.000Z","size":267,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-02T00:17:29.364Z","etag":null,"topics":["testing"],"latest_commit_sha":null,"homepage":"https://glebbahmutov.com/blog/using-test-ids-to-pick-specs-to-run/","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/bahmutov.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":"2023-09-08T20:59:00.000Z","updated_at":"2025-11-20T19:08:56.000Z","dependencies_parsed_at":"2023-09-08T22:58:57.591Z","dependency_job_id":"ef33ba60-b7db-48f2-af91-7865985d2ded","html_url":"https://github.com/bahmutov/changed-test-ids","commit_stats":{"total_commits":39,"total_committers":1,"mean_commits":39.0,"dds":0.0,"last_synced_commit":"f8477be090e1cc4090ed6da339f3ca26c7f615ed"},"previous_names":["bahmutov/changed-test-ids"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/bahmutov/changed-test-ids","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fchanged-test-ids","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fchanged-test-ids/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fchanged-test-ids/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fchanged-test-ids/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahmutov","download_url":"https://codeload.github.com/bahmutov/changed-test-ids/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fchanged-test-ids/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30087310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T15:40:14.053Z","status":"ssl_error","status_checked_at":"2026-03-04T15:40:13.655Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["testing"],"created_at":"2024-10-02T14:15:23.456Z","updated_at":"2026-03-04T17:31:09.965Z","avatar_url":"https://github.com/bahmutov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# changed-test-ids [![main](https://github.com/bahmutov/changed-test-ids/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bahmutov/changed-test-ids/actions/workflows/ci.yml)\n\n\u003e Select tests to run based on source file changes and test ids\n\n📝 Read the blog posts [Using Test Ids To Pick Cypress Specs To Run](https://glebbahmutov.com/blog/using-test-ids-to-pick-specs-to-run/) and [Pick Tests Using Test Ids From Another Source Repo](https://glebbahmutov.com/blog/pick-tests-in-another-repo/) and [How I Add Test Ids To Front-End Components](https://glebbahmutov.com/blog/how-i-add-test-ids/)\n\n## API\n\n- `findTestQueries`\n- `findTestQueriesInFile`\n- `findTestQueriesInFiles`\n- `findTestAttributes`\n- `findTestAttributesInFile`\n- `findTestAttributesInFiles`\n\n## Output\n\nList of data test ids, sorted alphabetically\n\n## CLI\n\n### Find test ids in the source files\n\n```\n$ npx find-ids --sources 'glob pattern to the JSX files'\n```\n\nOutputs the sorted list of test attributes, one per line. For example, use `npm run demo:sources`\n\nBy default, the utility prints a single test id per line. You can output a single comma-separated list by using the `--comma` argument\n\n```\n$ npx find-ids --sources 'glob pattern to the JSX files' --comma\n```\n\n### Find test ids used in Cypress specs\n\nLet's look through the Cypress specs for custom command `cy.getById` and find all unique arguments\n\n```\n$ npx find-ids --specs 'glob pattern to the Cypress specs' --command getById\n```\n\nOutputs the sorted list of test attributes, one per line. For example, use `npm run demo:specs`. You can use several custom commands, separate them using commas `--commands getById,containsByTest`. Specs could be TypeScript.\n\nIf you want to pick both JS and TS tests, use glob syntax. For example, let's grab all `.cy.js` and `.cy.ts` specs\n\n```\n--specs 'tests/fixtures/*.cy.{js,ts}'\n```\n\nTo produce verbose output showing specs for each test id, add argument `--verbose`. To output comma-separated test ids in a single line, use `--comma` argument.\n\n### Warn on untested ids\n\nIf you specify both sources and specs, then it will find all test ids used in the source files NOT used by the specs and list them one at a time\n\n```\n$ npx find-ids --sources ... --specs ... --command ...\n⚠️ found 1 test id(s) not covered by any specs\nname\n```\n\n### Print unused test ids\n\nInstead of warning about unused test ids, you can specifically only list all of them using a single comma-separated line\n\n```\n$ npx find-ids --specs ... --command ... --test-ids \"...\"\n```\n\nFor example, run\n\n```\n$ npm run demo:unused:ids\n\u003e node ./bin/find-ids --test-ids greeting,lastName,foo,bar --specs 'tests/fixtures/*.cy.js' --command getTest,findById --unused\n\n3 test ids were not used in any specs\nlastName,foo,bar\n```\n\nYou can read test ids from a text file, like [ids.txt](./ids.txt). This is useful since there might be a lot of test ids and passing them through the command-line becomes a problem.\n\n```\n$ npx find-ids --specs ... --command ... --test-ids-from-file \u003cfilename\u003e\n```\n\n### Specs to run based on Git changes\n\nYou can automatically compute which specs use the test ids from the changed source in the current branch.\n\n```\n$ npx find-ids --sources ... --specs ... --command ... --branch \u003ccompare against branch name\u003e\n```\n\nIf running on GitHub Actions, you can set the detected spec filenames as outputs by adding `--set-gha-outputs`. This sets the output variables `specsToRun` (comma-separated list of specs) and `specsToRunN` (number of specs found based on test ids in the changed source files).\n\n**Note:** when finding the test ids in the changed source files, we consider the source code _before_ and _after_ the change. For example, imagine in your branch you _delete_ a source file `Buttons.jsx`. We want to check the test ids from that source file against the specs!\n\n### Test ids based on Git changes\n\nYou can simply detect test ids in the changed source files and output their list.\n\n```\n$ npx find-ids --sources --branch \u003ccompare against branch name\u003e\n```\n\nIf running on GitHub Actions, use `--set-gha-outputs` to set the list of detected test ids `changedTestIds` and the number `changedTestIdsN`. Any unused test ids will be set into outputs `unusedTestIds` and `unusedTestIdsN`.\n\n### Find specs that use particular test ids\n\n```\n$ npx find-ids --specs ... --command ... --test-ids one,two\n```\n\nFor example, to find all specs ending in `.cy.js` and `.cy.ts` files and that use custom command `cy.getBy` and use test id `greeting`\n\n```\n$ npx find-ids --specs 'cypress/e2e/**/*.cy.{js,ts}' --command getBy --test-ids greeting\n```\n\nYou can output detailed information showing each spec using a test id by adding parameter `--verbose`\n\n```\n$ npx find-ids --specs 'cypress/e2e/**/*.cy.{js,ts}' --command getBy --test-ids greeting --verbose\n```\n\n## Debugging\n\nThis module uses [debug](https://github.com/debug-js/debug#readme) to output verbose logs. To see the logs, run with the following environment variable `DEBUG=changed-test-ids`\n\nIf a source file or a spec have syntax that cannot be parsed, they are ignored. You can see a debug message `changed-test-ids ⚠️ could not parse spec \u003cfilename\u003e +0ms`\n\n## Examples\n\n- repo [bahmutov/taste-the-sauce-test-ids](https://github.com/bahmutov/taste-the-sauce-test-ids)\n\n### Find sources in two folders\n\nLet's say we want to find data attributes in all source files in the subfolders `pages` and `components`.\n\n```\n$ npx find-ids --sources '{pages,components}/**/*.jsx'\n```\n\n## Small print\n\nAuthor: Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt; \u0026copy; 2023\n\n- [@bahmutov](https://twitter.com/bahmutov)\n- [glebbahmutov.com](https://glebbahmutov.com)\n- [blog](https://glebbahmutov.com/blog)\n- [videos](https://www.youtube.com/glebbahmutov)\n- [presentations](https://slides.com/bahmutov)\n- [cypress.tips](https://cypress.tips)\n- [Cypress Tips \u0026 Tricks Newsletter](https://cypresstips.substack.com/)\n- [my Cypress courses](https://cypress.tips/courses)\n\nLicense: MIT - do anything with the code, but don't blame me if it does not work.\n\nSupport: if you find any problems with this module, email / tweet /\n[open issue](https://github.com/bahmutov/changed-test-ids/issues) on Github\n\n## MIT License\n\nCopyright (c) 2023 Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt;\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fchanged-test-ids","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahmutov%2Fchanged-test-ids","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fchanged-test-ids/lists"}