{"id":13727115,"url":"https://github.com/playwright-community/jest-process-manager","last_synced_at":"2025-06-25T18:35:35.496Z","repository":{"id":42808282,"uuid":"262547462","full_name":"playwright-community/jest-process-manager","owner":"playwright-community","description":"Starts a server before the Jest tests and tears it down after.","archived":false,"fork":false,"pushed_at":"2023-11-16T19:22:25.000Z","size":102,"stargazers_count":19,"open_issues_count":5,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-26T05:57:23.310Z","etag":null,"topics":["e2e-testing","jest","playwright"],"latest_commit_sha":null,"homepage":"https://playwright.tech/blog/tracking-frontend-coverage-with-playwright","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/playwright-community.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":"CODEOWNERS","security":null,"support":null,"governance":null}},"created_at":"2020-05-09T10:36:07.000Z","updated_at":"2024-06-14T14:35:18.000Z","dependencies_parsed_at":"2023-11-14T20:39:00.512Z","dependency_job_id":null,"html_url":"https://github.com/playwright-community/jest-process-manager","commit_stats":{"total_commits":39,"total_committers":5,"mean_commits":7.8,"dds":0.3846153846153846,"last_synced_commit":"f09f75e4c8605383148611f2f1ea4ff637190025"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/playwright-community/jest-process-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playwright-community%2Fjest-process-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playwright-community%2Fjest-process-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playwright-community%2Fjest-process-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playwright-community%2Fjest-process-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/playwright-community","download_url":"https://codeload.github.com/playwright-community/jest-process-manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playwright-community%2Fjest-process-manager/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261931531,"owners_count":23232102,"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":["e2e-testing","jest","playwright"],"created_at":"2024-08-03T01:03:39.984Z","updated_at":"2025-06-25T18:35:35.471Z","avatar_url":"https://github.com/playwright-community.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# jest-process-manager\n\n**This project was forked because the package [`jest-dev-server`](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-dev-server) is no longer maintained.**\n\n[![CI](https://github.com/playwright-community/jest-process-manager/workflows/CI/badge.svg)](https://github.com/playwright-community/jest-process-manager/actions)\n[![npm](https://img.shields.io/npm/v/jest-process-manager)](http://npmjs.com/package/jest-process-manager)\n\nStarts a server before your Jest tests and tears it down after.\n\n## Why\n\n[`jest-playwright-preset`](https://github.com/playwright-community/jest-playwright) or `jest-puppeteer` works great for running tests in Jest using your preferred end-to-end testing library.\nIt's also useful for starting a local development server during the tests without letting Jest hang.\nThis package extracts just the local development server spawning without any ties to Puppeteer.\n\n## Install\n\n```bash\nnpm install --save-dev jest-process-manager\n```\n\n## Usage\n\n`jest-process-manager` exports `setup`,`teardown` and `getServers` functions.\n\n```js\n// global-setup.js\nconst { setup: setupDevServer } = require('jest-process-manager')\n\nmodule.exports = async function globalSetup() {\n  await setupDevServer({\n    command: `node config/start.js --port=3000`,\n    launchTimeout: 50000,\n    port: 3000,\n  })\n  // Your global setup\n}\n```\n\nIt is also possible to specify several servers:\n\n```js\n// global-setup.js\nconst { setup: setupDevServer } = require('jest-process-manager')\n\nmodule.exports = async function globalSetup() {\n  await setupDevServer([\n    {\n      command: 'node server.js',\n      port: 4444,\n    },\n    {\n      command: 'node server2.js',\n      port: 4445,\n    },\n  ])\n  // Your global setup\n}\n```\n\n```js\n// global-setup.js\nconst { setup: setupDevServer, getServers } = require('jest-process-manager')\n\nmodule.exports = async function globalSetup() {\n  await setupDevServer({\n    command: `node config/start.js --port=3000`,\n    launchTimeout: 50000,\n    port: 3000,\n  })\n  getServers.then(servers =\u003e {\n    // You can get to the servers and do whatever you want\n  })\n  // Your global setup\n}\n```\n\n```js\n// global-teardown.js\nconst { teardown: teardownDevServer } = require('jest-process-manager')\n\nmodule.exports = async function globalTeardown() {\n  await teardownDevServer()\n  // Your global teardown\n}\n```\n\n## Options\n\n### `command`\n\nType: `string`, required.\n\nCommand to execute to start the port.\nDirectly passed to [`spawnd`](https://www.npmjs.com/package/spawnd).\n\n```js\nmodule.exports = {\n  command: 'npm run start',\n}\n```\n\n### `debug`\n\nType: `boolean`, default to `false`.\n\nLog server output, useful if server is crashing at start.\n\n```js\nmodule.exports = {\n  command: 'npm run start',\n  debug: true,\n}\n```\n\n### `launchTimeout`\n\nType: `number`, default to `5000`.\n\nHow many milliseconds to wait for the spawned server to be available before giving up.\nDefaults to [`wait-port`](https://www.npmjs.com/package/wait-port)'s default.\n\n```js\nmodule.exports = {\n  command: 'npm run start',\n  launchTimeout: 30000,\n}\n```\n\n---\n\nFollowing options are linked to [`spawnd`](https://www.npmjs.com/package/spawnd).\n\n### `host`\n\nType: `string`, default to `localhost`.\n\nHost to wait for activity on before considering the server running.\nMust be used in conjunction with `port`.\n\n```js\nmodule.exports = {\n  command: 'npm run start --port 3000',\n  host: 'customhost.com',\n  port: 3000,\n}\n```\n\n### `protocol`\n\nType: (`https`, `http`, `http-get`, `https-get`, `tcp`, `socket`) default to `tcp`.\n\nTo wait for an HTTP or TCP endpoint before considering the server running, include `http` or `tcp` as a protocol.\nMust be used in conjunction with `port`.\nThis give you ability to define resource prefix for [`wait-on`](https://github.com/jeffbski/wait-on) package.\n\n```js\nmodule.exports = {\n  command: 'npm run start --port 3000',\n  protocol: 'http',\n  port: 3000,\n}\n```\n\n### `port`\n\nType: `number`, default to `3000`.\n\nPort to wait for activity on before considering the server running.\nIf not provided, the server is assumed to immediately be running.\n\n```js\nmodule.exports = {\n  command: 'npm run start --port 3000',\n  port: 3000,\n}\n```\n\n### `basePath`\n\nType: `string`\n\nOption for a basePath where server is running.\n\n```js\nmodule.exports = {\n  command: 'npm run start',\n  basePath: '/myservice',\n}\n```\n\n### `usedPortAction`\n\nType: `string` (`ask`, `error`, `ignore`, `kill`) default to `ask`.\n\nIt defines the action to take if port is already used:\n\n- `ask`: a prompt is shown to decide if you want to kill the process or not\n- `error`: an errow is thrown\n- `ignore`: your test are executed, we assume that the server is already started\n- `kill`: the process is automatically killed without a prompt\n\n```js\nmodule.exports = {\n  command: 'npm run start --port 3000',\n  port: 3000,\n  usedPortAction: 'kill',\n}\n```\n\n### `waitOnScheme`\n\n`jest-dev-server` use the [`wait-on`](https://www.npmjs.com/package/wait-on) npm package to wait for resources to become available before calling callback.\n\nType: `object`, default to `{}`.\n\n- `delay`: optional initial delay in ms, default 0\n- `interval`: optional poll resource interval in ms, default 250ms\n- `log`: optional flag which outputs to stdout, remaining resources waited on and when complete or errored\n- `reverse`: optional flag to reverse operation so checks are for resources being NOT available, default false\n- `timeout`: optional timeout in ms, default Infinity. Aborts with error\n- `tcpTimeout`: optional tcp timeout in ms, default 300ms\n- `verbose`: optional flag which outputs debug output, default false\n- `window`: optional stabilization time in ms, default 750ms. Waits this amount of time for file sizes to stabilize or other resource availability to remain unchanged\n\n**Note:** http(s) specific options, see https://github.com/request/request#readme for specific details\n\n```js\nmodule.exports = {\n  command: 'npm run start --port 3000',\n  port: 3000,\n  usedPortAction: 'kill',\n  waitOnScheme: {\n    delay: 1000,\n  },\n}\n```\n\n### `options`\n\nOptions which will be passed down to the [spawn](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) of the process. For example environment variables:\n\n```js\n// global-setup.js\nconst { setup: setupDevServer, getServers } = require('jest-process-manager')\n\nmodule.exports = async function globalSetup() {\n  await setupDevServer({\n    command: `node config/start.js --port=3000`,\n    launchTimeout: 50000,\n    port: 3000,\n    options: {\n      env: {\n        \"FOO\": \"bar\",\n      }\n    }\n  })\n  getServers.then(servers =\u003e {\n    // You can get to the servers and do whatever you want\n  })\n  // Your global setup\n}\n```\n\n## Troubleshooting\n\n- If using `port` makes the terminal to ask for root password although the port is valid and accessible then use `usePortAction: 'ignore'`.\n\n## License\n\nhttps://github.com/playwright-community/jest-process-manager/blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaywright-community%2Fjest-process-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplaywright-community%2Fjest-process-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaywright-community%2Fjest-process-manager/lists"}