{"id":29871405,"url":"https://github.com/drdxk/testonly","last_synced_at":"2026-01-20T16:39:26.483Z","repository":{"id":307200817,"uuid":"1028693061","full_name":"drdxk/testonly","owner":"drdxk","description":"mark files as testonly by importing this package","archived":false,"fork":false,"pushed_at":"2025-07-30T00:54:18.000Z","size":141,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-08T01:42:09.105Z","etag":null,"topics":["node","nodejs","testing","typescript"],"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/drdxk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2025-07-29T23:28:45.000Z","updated_at":"2025-07-30T00:54:21.000Z","dependencies_parsed_at":"2025-07-30T01:45:04.964Z","dependency_job_id":"9eee6033-e232-46b1-be01-2402bba68a1d","html_url":"https://github.com/drdxk/testonly","commit_stats":null,"previous_names":["drdxk/testonly"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/drdxk/testonly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drdxk%2Ftestonly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drdxk%2Ftestonly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drdxk%2Ftestonly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drdxk%2Ftestonly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drdxk","download_url":"https://codeload.github.com/drdxk/testonly/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drdxk%2Ftestonly/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000960,"owners_count":26082973,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["node","nodejs","testing","typescript"],"created_at":"2025-07-30T19:46:02.855Z","updated_at":"2025-10-09T07:33:29.598Z","avatar_url":"https://github.com/drdxk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mark-testonly\n\nImporting this file when `NODE_ENV !== 'test'` throws an error.\n\nThis allows marking `.js` / `.ts` files as \"test only\" by importing this\npackage. Import should be done as a side effect import.\n\nRecommendation: make it the first import in your files.\n\n## Installation\n\n```shell\nnpm install mark-testonly --save\n```\n\n\u003e _**Why not `--save-dev`?** Because this package might get lost in production,\n\u003e and instead of throwing it would produce a missing import error, which might\n\u003e be a bit more confusing._\n\n## Usage\n\n### Mark a file as test-only\n\nSimply import as a side effect in a test file to mark that file as test-only:\n\n```typescript\n// my-test-util.ts\nimport 'mark-testonly'; // This throws in non-test environment\n\n// .. rest of the file\n```\n\n```javascript\n// my-legacy-test-util.cjs\nrequire('mark-testonly'); // This throws in non-test environment\n\n// .. rest of the file\n```\n\nIt doesn't matter where exactly it is imported, however it is recommended to\nimport it as the first import in the file.\n\n\u003e _**Reminder**: import declarations are\n\u003e [hoisted](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#hoisting)._\n\n### Mark a function as test-only\n\n```typescript\n// my-lib.ts\nimport {setTestOnly} from 'mark-testonly/fn';\n\nexport function setTestingHooks() {\n  setTestOnly(); // This throws in non-test environment\n  // ...function logic...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrdxk%2Ftestonly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrdxk%2Ftestonly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrdxk%2Ftestonly/lists"}