{"id":28323277,"url":"https://github.com/adequatica/api-testing","last_synced_at":"2026-04-28T17:34:41.565Z","repository":{"id":141297059,"uuid":"412148216","full_name":"adequatica/api-testing","owner":"adequatica","description":"Testing API with TypeScript, Jest, and Got","archived":false,"fork":false,"pushed_at":"2024-06-08T12:11:56.000Z","size":113,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-23T22:42:28.692Z","etag":null,"topics":["jest","testing"],"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/adequatica.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,"zenodo":null}},"created_at":"2021-09-30T16:52:59.000Z","updated_at":"2024-06-08T12:12:00.000Z","dependencies_parsed_at":"2025-06-23T22:33:07.719Z","dependency_job_id":"a1f8f833-8194-41c4-8c7e-5a5c355af6e0","html_url":"https://github.com/adequatica/api-testing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adequatica/api-testing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adequatica%2Fapi-testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adequatica%2Fapi-testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adequatica%2Fapi-testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adequatica%2Fapi-testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adequatica","download_url":"https://codeload.github.com/adequatica/api-testing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adequatica%2Fapi-testing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32392300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"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":["jest","testing"],"created_at":"2025-05-25T15:11:19.246Z","updated_at":"2026-04-28T17:34:41.550Z","avatar_url":"https://github.com/adequatica.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# API Testing with TypeScript, Jest, and Got\n\nDisclaimer: I consider the stack below to be outdated. Contemporary API testing stack on [Vitest](https://vitest.dev/) + Node.js [`fetch()`](https://nodejs.org/dist/latest-v21.x/docs/api/globals.html#fetch) can be found [here](https://github.com/adequatica/api-vitesting).\n\n## Stack\n\nA basic set of packages to test API with TypeScript and HTTP client:\n\n- [Jest](https://jestjs.io) — testing framework;\n- [Jest-extended](https://jest-extended.jestcommunity.dev) — additional Jest matchers;\n- [Got](https://github.com/sindresorhus/got) — library for HTTP requests;\n- [Ajv](https://ajv.js.org) — JSON schema validator;\n- [date-fns](https://date-fns.org) — library for dates;\n- [Prettier](https://prettier.io) — code formatter;\n- [ESLint](https://eslint.org/) – code linter.\n\nExample API for testing: [APOD NASA API](https://api.nasa.gov).\n\n## How to Use\n\n1. Clone repository\n2. Install dependencies: `npm install`\n3. Run tests: `npm run test`\n\n### CLI Options\n\n- Different tested host could be passed to tests through `.env` variable (it can be useful for testing different environments):\n\n`HOST=https://api.nasa.gov npm test`\n\n- Individual API key could be passed to tests through `.env` variable (otherwise, it will be used `DEMO_KEY` value):\n\n`API_KEY={api_key} npm test`\n\n- Run a single test or tests [that match a specific filename](https://jestjs.io/docs/cli#running-from-the-command-line) (for example `epic.test.ts`):\n\n`npm test epic`\n\n## Examples of Test Cases\n\n- `apod.test.ts` — test with JSON schema validation;\n- `epic.test.ts` — test has [a loop through array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) for checking elements with jest-extended assert;\n- `insight-weather.test.ts` — test will be conditionally [skipped](https://jestjs.io/docs/api#describeskipname-fn) in an inappropriate environment.\n\n---\n\n### Story about updating packages (2023-11-23) to the latest versions\n\nThere were a lot of problems with the last versions of configuration Got and Jest and TypeScript:\n\n1. Got from the 12 version requires only ESM and requires:\n   - `\"module\": \"node16\",`\n   - `\"moduleResolution\": \"node16\"` in tsconfig file (as it told in [the last release notes](https://github.com/sindresorhus/got/releases/tag/v13.0.0));\n2. Due to the setting above, if you import .ts files inside your .ts files (like I do to import utils' functions inside tests), you need to add:\n   - `\"noEmit\": true,`\n   - `\"emitDeclarationOnly\": false,`\n   - `\"allowImportingTsExtensions\": true` in tsconfig file too;\n3. Then you need to add `\"type\": \"module\"` in `package.json` for using `import` in .ts files;\n4. But with this setting, the whole Jest stops working and requires a different launch method, as told in Jest's documentation about [experimental support for ECMAScript Modules](https://jestjs.io/docs/ecmascript-modules):\n   - `node --experimental-vm-modules ./node_modules/.bin/jest`\n5. And even this does not work without [ts-jest](https://github.com/kulshekhar/ts-jest) package and jest.config.ts settings:\n   - `transform: {'^.+\\\\.(ts|tsx)?$': ['ts-jest', { useESM: true }]},`\n   - `extensionsToTreatAsEsm: ['.ts']`\n6. Last but not least, changing filetype from `jest.config.js` to `jest.config.ts` leads to more configuration changes (I don't remember how)…\n\nI would recommend using [Axios](https://axios-http.com/) as an HTTP client to make setup process much easier (if you do not need specific features of Got). But in this repository, I continue to use Got, because _this is the way._\n\nExample of Jest + Axios can be found [here](https://github.com/adequatica/api-testing-comparison).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadequatica%2Fapi-testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadequatica%2Fapi-testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadequatica%2Fapi-testing/lists"}