{"id":21198844,"url":"https://github.com/natlibfi/fixugen-http-server-js","last_synced_at":"2025-06-27T10:08:23.017Z","repository":{"id":57129406,"uuid":"274118340","full_name":"NatLibFi/fixugen-http-server-js","owner":"NatLibFi","description":"Generate unit tests for HTTP servers with fixugen","archived":false,"fork":false,"pushed_at":"2025-06-26T09:16:00.000Z","size":1212,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-26T10:20:45.456Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NatLibFi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-06-22T11:26:23.000Z","updated_at":"2025-06-26T09:15:10.000Z","dependencies_parsed_at":"2023-12-12T12:30:17.301Z","dependency_job_id":"4564b1ae-6cbe-4785-b5a9-44edf29fe0d5","html_url":"https://github.com/NatLibFi/fixugen-http-server-js","commit_stats":{"total_commits":19,"total_committers":4,"mean_commits":4.75,"dds":"0.42105263157894735","last_synced_commit":"28d001ad270e911c80ad99b93971479f2cdd2e9e"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"purl":"pkg:github/NatLibFi/fixugen-http-server-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatLibFi%2Ffixugen-http-server-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatLibFi%2Ffixugen-http-server-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatLibFi%2Ffixugen-http-server-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatLibFi%2Ffixugen-http-server-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NatLibFi","download_url":"https://codeload.github.com/NatLibFi/fixugen-http-server-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatLibFi%2Ffixugen-http-server-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262235784,"owners_count":23279567,"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-20T19:53:44.452Z","updated_at":"2025-06-27T10:08:23.003Z","avatar_url":"https://github.com/NatLibFi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Generate unit tests for HTTP servers with fixugen\n[![NPM Version](https://img.shields.io/npm/v/@natlibfi/fixugen-http-server.svg)](https://npmjs.org/package/@natlibfi/fixugen-http-server) [![Node Version](https://img.shields.io/node/v/@natlibfi/fixugen-http-server.svg)]()\n\n\nGenerates unit tests with fixugen and [chai-http](). Starts a HTTP server which is tested with generic HTTP request and response expectations.\n\nUses [fixugen's](https://www.npmjs.com/package/@natlibfi/fixugen) **useMetadataFile** so your fixture directories must contain **metadata.json** file.\n\n# Usage\n```js\nimport generateTests from '@natlibfi/fixugen-http-server';\nimport startApp from './app';\n\ngenerateTests({\n  callback: () =\u003e startApp(),\n  path: [__dirname, '..', '..', 'test-fixtures', 'app']\n});\n\n```\n# Configuration\nAn array property **requests** must be present in **metadata.json** file. It supports the following properties:\n- **status**: HTTP status code (Number). **Mandatory**.\n- **method**: HTTP method in lowercase. **Mandatory**.\n- **path**: URL path. Defaults to `/`\n- **requestHeaders**: An object representing requests headers.\n- **responseHeaders**: An object representing response headers.\n\nThis configuration is also passed to the callback as the property **requests**.\n\n# Request and response payloads\nThe fixture directory for each unit test can have request- and response payload fixtures which must match the following filename pattern:\n`/^request[0-9]+`\n`/^response[0-9]+`\n\n# Formatting the response\nPass a callback to the exported function to format response headers and payload:\n```js\ngenerateTests({\n  formatResponse,\n  callback: () =\u003e startApp(),\n  path: [__dirname, '..', '..', 'test-fixtures', 'app']\n});\n\nfunction formatResponse(headers, payload) {\n  const newHeaders = doSomethingWithHeaders();\n  return { payload, headers: newHeaders };\n}\n```\n\nWhere `[0-9]+` denotes the index number of the fixture (Requests and responses are mocked in that order).\n\n## License and copyright\n\nCopyright (c) 2020, 2022-2025 **University Of Helsinki (The National Library Of Finland)**\n\nThis project's source code is licensed under the terms of **MIT** or any later version.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatlibfi%2Ffixugen-http-server-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnatlibfi%2Ffixugen-http-server-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatlibfi%2Ffixugen-http-server-js/lists"}