Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,32 @@ module.exports = {
}
```

### `options`

Options 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:

```js
// global-setup.js
const { setup: setupDevServer, getServers } = require('jest-process-manager')

module.exports = async function globalSetup() {
await setupDevServer({
command: `node config/start.js --port=3000`,
launchTimeout: 50000,
port: 3000,
options: {
env: {
"FOO": "bar",
}
}
})
getServers.then(servers => {
// You can get to the servers and do whatever you want
})
// Your global setup
}
```

## Troubleshooting

- If using `port` makes the terminal to ask for root password although the port is valid and accessible then use `usePortAction: 'ignore'`.
Expand Down
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ function runServer(config: JestProcessManagerOptions, index: number) {

servers[index] = spawnd(config.command, {
shell: true,
env: process.env,
cwd: cwd(),
...config.options,
env: {
...process.env,
...(config.options?.env ? config.options.env : {})
}
})

if (config.debug) {
Expand Down Expand Up @@ -222,8 +225,8 @@ async function setupJestServer(providedConfig: JestProcessManagerOptions, index:
await waitOn(opts)
} catch (err) {
throw new JestProcessManagerError(
`Server has taken more than ${launchTimeout}ms to start.`,
ERROR_TIMEOUT,
`Server has taken more than ${launchTimeout}ms to start.`,
ERROR_TIMEOUT,
)
}
} else {
Expand Down