Skip to content

Commit f772d74

Browse files
xiaoyuhengregberge
authored andcommitted
feat: add waitOnScheme options (#232)
1 parent a415654 commit f772d74

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

packages/jest-dev-server/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,34 @@ module.exports = {
189189
}
190190
```
191191

192+
### `waitOnScheme`
193+
194+
`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.
195+
196+
Type: `object`, default to `{}`.
197+
198+
- `delay`: optional initial delay in ms, default 0
199+
- `interval`: optional poll resource interval in ms, default 250ms
200+
- `log`: optional flag which outputs to stdout, remaining resources waited on and when complete or errored
201+
- `reverse`: optional flag to reverse operation so checks are for resources being NOT available, default false
202+
- `timeout`: optional timeout in ms, default Infinity. Aborts with error
203+
- `tcpTimeout`: optional tcp timeout in ms, default 300ms
204+
- `verbose`: optional flag which outputs debug output, default false
205+
- `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
206+
207+
**Note:** http(s) specific options, see https://github.com/request/request#readme for specific details
208+
209+
```js
210+
module.exports = {
211+
command: 'npm run start --port 3000',
212+
port: 3000,
213+
usedPortAction: 'kill',
214+
waitOnScheme: {
215+
delay: 1000,
216+
},
217+
}
218+
```
219+
192220
## Troubleshooting
193221

194222
- If using `port` makes the terminal to ask for root password although the port is valid and accessible then use `usePortAction: 'ignore'`.

packages/jest-dev-server/src/global.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const DEFAULT_CONFIG = {
1818
port: null,
1919
protocol: 'http',
2020
usedPortAction: 'ask',
21+
waitOnScheme: {},
2122
}
2223

2324
const pTreeKill = promisify(treeKill)
@@ -186,10 +187,11 @@ async function setupJestServer(providedConfig, index) {
186187
}
187188

188189
if (config.port) {
189-
const { launchTimeout, protocol, host, port } = config
190+
const { launchTimeout, protocol, host, port, waitOnScheme } = config
190191

191192
const opts = {
192193
resources: [`${protocol}://${host}:${port}`],
194+
...waitOnScheme,
193195
}
194196

195197
let timeout

0 commit comments

Comments
 (0)