{"id":15253545,"url":"https://github.com/janaz/in-process-request","last_synced_at":"2026-02-18T14:01:39.300Z","repository":{"id":35017205,"uuid":"193335689","full_name":"janaz/in-process-request","owner":"janaz","description":"Node.js library for calling http hander function","archived":false,"fork":false,"pushed_at":"2023-01-12T01:50:06.000Z","size":1189,"stargazers_count":0,"open_issues_count":17,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-30T16:37:52.492Z","etag":null,"topics":["connectjs","express","expressjs","http","koa","koa2","koajs","mock","request","response","test"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/janaz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-23T10:40:51.000Z","updated_at":"2022-04-10T02:01:45.000Z","dependencies_parsed_at":"2023-01-15T12:05:38.895Z","dependency_job_id":null,"html_url":"https://github.com/janaz/in-process-request","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/janaz/in-process-request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janaz%2Fin-process-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janaz%2Fin-process-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janaz%2Fin-process-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janaz%2Fin-process-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janaz","download_url":"https://codeload.github.com/janaz/in-process-request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janaz%2Fin-process-request/sbom","scorecard":{"id":504872,"data":{"date":"2025-08-11","repo":{"name":"github.com/janaz/in-process-request","commit":"31671426362ab11efa65835517165b950be485ed"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/24 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":6,"reason":"dependency not pinned by hash detected -- score normalized to 6","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/janaz/in-process-request/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/janaz/in-process-request/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/janaz/in-process-request/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/janaz/in-process-request/publish.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/main.yml:21","Warn: npmCommand not pinned by hash: .github/workflows/publish.yml:17","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:  12 out of  14 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"54 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-j5g3-5c8r-7qfx","Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-wm7h-9275-46v2","Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc","Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-j4mr-9xw3-c9jx","Warn: Project is vulnerable to: GHSA-7p89-p6hx-q4fw","Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-cm5g-3pgc-8rg4","Warn: Project is vulnerable to: GHSA-jj78-5fmv-mv28","Warn: Project is vulnerable to: GHSA-9qj9-36jm-prpv","Warn: Project is vulnerable to: GHSA-wrvr-8mpx-r7pp","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-gwg9-rgvj-4h5j","Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f","Warn: Project is vulnerable to: GHSA-7mc5-chhp-fmc3","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-gqgv-6jq5-jjj9","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3fjj-p79j-c9hh","Warn: Project is vulnerable to: GHSA-rrr8-f88r-h8q6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-593f-38f6-jp5m","Warn: Project is vulnerable to: GHSA-x2rg-q646-7m2v","Warn: Project is vulnerable to: GHSA-jgmv-j7ww-jx2x","Warn: Project is vulnerable to: GHSA-29xr-v42j-r956","Warn: Project is vulnerable to: GHSA-cj7v-w2c7-cp7c","Warn: Project is vulnerable to: GHSA-4jpv-8r57-pv7j","Warn: Project is vulnerable to: GHSA-cph5-m8f7-6c5x","Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx","Warn: Project is vulnerable to: GHSA-jr5f-v2jv-69x6","Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc","Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-7f5c-rpf4-86p8","Warn: Project is vulnerable to: GHSA-44fp-w29j-9vj5","Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T23:03:42.177Z","repository_id":35017205,"created_at":"2025-08-19T23:03:42.177Z","updated_at":"2025-08-19T23:03:42.177Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278855639,"owners_count":26057710,"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-07T02:00:06.786Z","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":["connectjs","express","expressjs","http","koa","koa2","koajs","mock","request","response","test"],"created_at":"2024-09-29T21:05:24.748Z","updated_at":"2025-10-07T22:17:00.583Z","avatar_url":"https://github.com/janaz.png","language":"TypeScript","readme":"# in-process-request\n\nA node.js library that executes a http handler function in the current process without having to start a local http server.\n\n[![Build Status](https://travis-ci.org/janaz/in-process-request.svg?branch=master)](https://travis-ci.org/janaz/in-process-request)\n\nIt supports the following frameworks\n\n- Express.js v3\n- Express.js v4\n- Express.js v5\n- Apollo Server v2\n- Apollo Server v3\n- Hapi v19\n- Hapi v20\n- NestJS v7\n- Connect v3\n- Koa v2\n- Polka\n- Fastify v3\n- Fastify v4\n- More to come...\n\nIt has been tested with the following node versions\n\n- v14\n- v16\n- v18\n- v19\n\n## Usage\n\n```sh\n$ npm install in-process-request\n```\n\n```javascript\nconst inProcessRequest = require(\"in-process-request\")\n\nconst handler = inProcessRequest(app)\nhandler(requestOptions).then((response) =\u003e {\n  console.log(response)\n  // do something with the response\n})\n```\n\n`requestOptions` is an object with the following properties\n\n- `path` (**mandatory**) - The request path with optional query string, for example `'/my/resource/123?full=true'`\n- `method` - request method, the default is `'GET'`\n- `body` - request body, `string` or `Buffer`\n- `headers` - request headers object, for example: `{'conent-type': 'application/json'}`\n- `remoteAddress` - IP address of the client making the request\n- `remotePort` - IP port of the client connection\n- `ssl` - Set to `true` to pretend that SSL connection is used. Defaults to `false`\n\n`response` is an object with the following properties\n\n- `statusCode` - status code of the response\n- `statusMessage` - status message of the response\n- `headers` - object with response headers\n- `body` - `Buffer` containing the body\n- `isUTF8` - set to `true` if the response is a utf-8 string. In that case `response.body.toString()` can be used to extract the utf-8 string\n\n### Express.js example\n\n```javascript\nconst inProcessRequest = require(\"in-process-request\")\nconst express = require(\"express\")\n\nconst myApp = express()\nmyApp.get(\"/test\", (req, res) =\u003e {\n  res.json({ ok: true, a: req.query.a })\n})\n\nconst myAppHandler = inProcessRequest(myApp)\n\nconst requestOptions = {\n  path: \"/test\",\n  method: \"GET\",\n}\n\nmyAppHandler(requestOptions).then((response) =\u003e {\n  console.log(\"Body\", response.body)\n  console.log(\"Headers\", response.headers)\n  console.log(\"Status Code\", response.statusCode)\n  console.log(\"Status Message\", response.statusMessage)\n  console.log(\"Is UTF8 body?\", response.isUTF8)\n})\n```\n\n### Koa example\n\n```javascript\nconst inProcessRequest = require(\"in-process-request\")\nconst Koa = require(\"koa\")\nconst serve = require(\"koa-static\")\nconst mount = require(\"koa-mount\")\nconst Router = require(\"koa-router\")\n\nconst koa = new Koa()\n\nconst router = new Router()\n\nrouter.get(\"/test\", (ctx) =\u003e {\n  ctx.body = \"Hello\"\n})\n\nkoa.use(router.routes())\n\n// koa.callback() returns the requestListener functions\nconst myApp = koa.callback()\n\nconst myAppHandler = inProcessRequest(myApp)\n\nconst requestOptions = {\n  path: \"/test\",\n  method: \"GET\",\n}\n\nmyAppHandler(requestOptions).then((response) =\u003e {\n  console.log(\"Body\", response.body)\n  console.log(\"Headers\", response.headers)\n  console.log(\"Status Code\", response.statusCode)\n  console.log(\"Status Message\", response.statusMessage)\n  console.log(\"Is UTF8 body?\", response.isUTF8)\n})\n```\n\n### Hapi example\n\nIn order to get access to the `requestListener` function in Hapi we need to use custom `listener` object. The `in-process-request` module comes with a helper class `HapiListener` that makes it easy. An instance of this class is used as the listener and the `handler` property of that instance provides the request listener function.\n\n```javascript\nconst inProcessRequest = require(\"in-process-request\")\nconst Hapi = require(\"@hapi/hapi\")\n\n// create custom listener for Hapi\nconst myListener = new inProcessRequest.HapiListener()\n\n// Pass the custom listener to Hapi.server\nconst server = Hapi.server({\n  listener: myListener,\n})\n\nserver.route({\n  method: \"GET\",\n  path: \"/\",\n  handler: (_request: any, _h: any) =\u003e {\n    return \"Hello World!\"\n  },\n})\n\nconst waitForServer = async () =\u003e {\n  //wait for the server to initialize\n  await server.start()\n  // return the request listener function\n  return myListener.handler\n}\n\nwaitForServer().then((myApp) =\u003e {\n  // The server is initialized and we have access to the request handler - myApp\n  const myAppHandler = inProcessRequest(myApp)\n\n  const requestOptions = {\n    path: \"/\",\n    method: \"GET\",\n  }\n\n  myAppHandler(requestOptions).then((response) =\u003e {\n    console.log(\"Body\", response.body)\n    console.log(\"Headers\", response.headers)\n    console.log(\"Status Code\", response.statusCode)\n    console.log(\"Status Message\", response.statusMessage)\n    console.log(\"Is UTF8 body?\", response.isUTF8)\n  })\n})\n```\n\n### NestJS example\n\nThis library provides a handy adapter for retrieving the underlying Express instance, which is needed for using this library to send requests to NestJS app.\n\n```typescript\nimport inProcessRequest from \"in-process-request\"\n\nimport { NestFactory } from \"@nestjs/core\"\nimport { Module, Get, Controller } from \"@nestjs/common\"\nimport { NestExpressApplication } from \"@nestjs/platform-express\"\n\n@Controller()\nclass AppController {\n  @Get()\n  render() {\n    return { hello: \"world\" }\n  }\n}\n\n@Module({\n  imports: [],\n  controllers: [AppController],\n})\nclass AppModule {}\n\nconst getApp = async () =\u003e {\n  const app = await NestFactory.create\u003cNestExpressApplication\u003e(AppModule)\n\n  return await inProcessRequest.nestHandler(app)\n}\n\ngetApp().then((myApp) =\u003e {\n  // The server is initialized and we have access to the request handler - myApp\n  const myAppHandler = inProcessRequest(myApp)\n\n  const requestOptions = {\n    path: \"/\",\n    method: \"GET\",\n  }\n\n  myAppHandler(requestOptions).then((response) =\u003e {\n    console.log(\"Body\", response.body)\n    console.log(\"Headers\", response.headers)\n    console.log(\"Status Code\", response.statusCode)\n    console.log(\"Status Message\", response.statusMessage)\n    console.log(\"Is UTF8 body?\", response.isUTF8)\n  })\n})\n```\n\n### Fastify v3 example\n\nThis library provides an adapter for retrieving the underlying NodeJS server handler\n\n```javascript\nconst fastify = require(\"fastify\")\nconst inProcessRequest = require(\"in-process-request\")\n\nconst build = (options) =\u003e {\n  const app = fastify(options)\n  app.get(\"/\", async (_request, reply) =\u003e {\n    return { hello: \"world\" }\n  })\n\n  return app\n}\n\nconst fastifyOpts = { logger: false }\ninProcessRequest\n  .fastifyHandler(build)(fastifyOpts)\n  .then((myApp) =\u003e {\n    // The server is initialized and we have access to the request handler - myApp\n    const myAppHandler = inProcessRequest(myApp)\n\n    const requestOptions = {\n      path: \"/\",\n      method: \"GET\",\n    }\n\n    myAppHandler(requestOptions).then((response) =\u003e {\n      console.log(\"Body\", response.body)\n      console.log(\"Headers\", response.headers)\n      console.log(\"Status Code\", response.statusCode)\n      console.log(\"Status Message\", response.statusMessage)\n      console.log(\"Is UTF8 body?\", response.isUTF8)\n    })\n  })\n```\n\n### Fastify v4 example\n\nThis library provides an adapter for retrieving the underlying NodeJS server handler\n\n```javascript\nconst fastify = require(\"fastify\")\nconst inProcessRequest = require(\"in-process-request\")\n\nconst app = fastify({ logger: false })\napp.get(\"/\", (_request, _reply) =\u003e {\n  return { hello: \"world\" }\n})\n\ninProcessRequest\n  .fastifyV4Handler(app)\n  .then((myApp) =\u003e {\n    // The server is initialized and we have access to the request handler - myApp\n    const myAppHandler = inProcessRequest(myApp)\n\n    const requestOptions = {\n      path: \"/\",\n      method: \"GET\",\n    }\n\n    myAppHandler(requestOptions).then((response) =\u003e {\n      console.log(\"Body\", response.body)\n      console.log(\"Headers\", response.headers)\n      console.log(\"Status Code\", response.statusCode)\n      console.log(\"Status Message\", response.statusMessage)\n      console.log(\"Is UTF8 body?\", response.isUTF8)\n    })\n  })\n```\n\n\n### Polka example\n\n```javascript\nconst inProcessRequest = require(\"in-process-request\")\nconst polka = require(\"polka\")\n\nconst myApp = polka()\nmyApp.get(\"/test\", (req, res) =\u003e {\n  res.json({ ok: true, a: req.query.a })\n})\n\nconst myAppHandler = inProcessRequest(myApp.handler.bind(myApp))\n\nconst requestOptions = {\n  path: \"/test\",\n  method: \"GET\",\n}\n\nmyAppHandler(requestOptions).then((response) =\u003e {\n  console.log(\"Body\", response.body)\n  console.log(\"Headers\", response.headers)\n  console.log(\"Status Code\", response.statusCode)\n  console.log(\"Status Message\", response.statusMessage)\n  console.log(\"Is UTF8 body?\", response.isUTF8)\n})\n```\n\n## Usage in integration tests\n\n### Mocha / Chai\n\n```javascript\nconst { expect } = require(\"chai\")\nconst inProcessRequest = require(\"in-process-request\")\nconst express = require(\"express\")\nconst app = express()\n\napp.get(\"/test\", (req, res) =\u003e {\n  res.set(\"X-Hello\", \"world\")\n  res.json({ ok: true, a: req.query.a })\n})\n\ndescribe(\"handler\", () =\u003e {\n  it(\"responds with 200, custom header and query param in JSON body\", () =\u003e {\n    const reqOptions = {\n      path: \"/test?a=xyz\",\n      method: \"GET\",\n    }\n    return inProcessRequest(app)(reqOptions).then((response) =\u003e {\n      const json = JSON.parse(response.body.toString())\n      expect(json).to.deep.equal({ ok: true, a: \"xyz\" })\n      expect(response.headers[\"x-hello\"]).to.equal(\"world\")\n      expect(response.statusCode).to.equal(200)\n      expect(response.isUTF8).to.be.true\n    })\n  })\n\n  it(\"responds with 200, custom header and query param in JSON body\", (done) =\u003e {\n    const reqOptions = {\n      path: \"/test?a=xyz\",\n      method: \"GET\",\n    }\n    inProcessRequest(app)(reqOptions).then((response) =\u003e {\n      const json = JSON.parse(response.body.toString())\n      expect(json).to.deep.equal({ ok: true, a: \"xyz\" })\n      expect(response.headers[\"x-hello\"]).to.equal(\"world\")\n      expect(response.statusCode).to.equal(200)\n      expect(response.isUTF8).to.be.true\n      done()\n    })\n  })\n})\n```\n\n### Jest\n\n```javascript\nconst inProcessRequest = require(\"in-process-request\")\nconst express = require(\"express\")\nconst app = express()\n\napp.get(\"/test\", (req, res) =\u003e {\n  res.set(\"X-Hello\", \"world\")\n  res.json({ ok: true, a: req.query.a })\n})\n\ndescribe(\"handler\", () =\u003e {\n  it(\"responds with 200, custom header and query param in JSON body\", () =\u003e {\n    const reqOptions = {\n      path: \"/test?a=xyz\",\n      method: \"GET\",\n    }\n    return inProcessRequest(app)(reqOptions).then((response) =\u003e {\n      const json = JSON.parse(response.body.toString())\n      expect(json).toEqual({ ok: true, a: \"xyz\" })\n      expect(response.headers[\"x-hello\"]).toEequal(\"world\")\n      expect(response.statusCode).toEequal(200)\n      expect(response.isUTF8).to.be.true\n    })\n  })\n\n  it(\"responds with 200, custom header and query param in JSON body\", (done) =\u003e {\n    const reqOptions = {\n      path: \"/test?a=xyz\",\n      method: \"GET\",\n    }\n    inProcessRequest(app)(reqOptions).then((response) =\u003e {\n      const json = JSON.parse(response.body.toString())\n      expect(json).toEqual({ ok: true, a: \"xyz\" })\n      expect(response.headers[\"x-hello\"]).toEequal(\"world\")\n      expect(response.statusCode).toEequal(200)\n      expect(response.isUTF8).toBeTrue()\n      done()\n    })\n  })\n})\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanaz%2Fin-process-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanaz%2Fin-process-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanaz%2Fin-process-request/lists"}