Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-dev-server

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-dev-server - npm Package Compare versions

Comparing version 0.1.2 to 3.1.0

CHANGELOG.md

44

package.json
{
"name": "jest-dev-server",
"version": "0.1.2",
"description": "Creates and tears down a local dev server during Jest tests.",
"main": "./src/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/joshuakgoldberg/jest-dev-server.git"
},
"description": "Starts a server before your Jest tests and tears it down after.",
"version": "3.1.0",
"main": "index.js",
"repository": "https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-dev-server",
"author": "Greg Bergé <berge.greg@gmail.com>",
"license": "MIT",
"keywords": [
"jest",
"dev",
"server",
"localhost",
"config",
"tests"
"jest-environment",
"server"
],
"author": "Josh Goldberg <joshuakgoldberg@outlook.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/joshuakgoldberg/jest-dev-server/issues"
"scripts": {
"prebuild": "rm -rf lib/",
"build": "babel src -d lib --ignore \"*.test.js\"",
"dev": "yarn build --watch",
"prepublishOnly": "yarn build"
},
"homepage": "https://github.com/joshuakgoldberg/jest-dev-server#readme",
"dependencies": {
"chalk": "^2.4.1",
"cwd": "^0.10.0",
"lodash": "^4.17.10",
"mz": "^2.7.0",
"portscanner": "^2.2.0",
"find-process": "^1.1.1",
"inquirer": "^6.0.0",
"spawnd": "^2.0.0",
"terminate": "^2.1.0",
"wait-port": "^0.2.2"
},
"devDependencies": {
"@types/lodash": "^4.14.108",
"@types/mz": "0.0.32",
"@types/node": "^10.0.8",
"@types/portscanner": "^2.1.0",
"typescript": "^2.8.3"
}
}
# jest-dev-server
Shamelessly copy & pasted from `jest-puppeteer`'s [jest-environment-puppeteer](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer).
Starts a server before your Jest tests and tears it down after.
Obeys generally the same settings as `jest-environment-puppeteer`.

@@ -16,67 +13,54 @@ ## Why

First off, if you're writing tests with Puppeteer, use [`jest-puppeteer`](https://github.com/smooth-code/jest-puppeteer) instead.
`jest-dev-server` exports `setup` and `teardown` functions.
`jest-dev-server` exports `setupServer` and `teardownServer` functions.
`setupServer` will read in settings from `jest-dev-server-config.js`.
```js
// global-setup.js
const { setup: setupDevServer } = require('jest-dev-server')
```javascript
// globalSetup.js
module.exports = require("jest-dev-server").setupServer;
```
```javascript
// globalTeardown.js
module.exports = require("jest-dev-server").teardownServer;
```
```javascript
// jest-dev-server.config.js
module.exports = {
module.exports = async function globalSetup() {
await setupDevServer({
command: `node config/start.js --port=3000`,
launchTimeout: 50000,
port: 3000,
};
})
// Your global setup
}
```
#### Options
```js
// global-teardown.js
const { setup: teardownDevServer } = require('jest-dev-server')
#### `allowExistingServer`
module.exports = async function globalTeardown() {
await teardownDevServer()
// Your global teardown
}
```
Type: `boolean`.
#### Options
If true and `port` is specified, `jest-dev-server` will check if the port is in use and skip creating a server if so.
Useful to allow developers and CI machines to have a local server running that was started before tests run.
#### `command`
```javascript
module.exports = {
allowExistingServer: true,
command: "npm run start --port 3000",
port: 3000,
};
```
Type: `string`, required.
#### `args`
Command to execute to start the port.
Directly passed to [`spawnd`](https://www.npmjs.com/package/spawnd).
Type: `string[]`.
Any additional options to pass to `command`.
```javascript
```js
module.exports = {
args: ["--no-sandbox"],
command: "npm run start",
};
command: 'npm run start',
}
```
#### `command`
#### `debug`
Type: `string`.
Type: `boolean`, default to `false`.
Command to execute to start the port.
Directly passed to [`spawnd`](https://www.npmjs.com/package/spawnd).
Log server output, useful if server is crashing at start.
```javascript
```js
module.exports = {
command: "npm run start",
};
command: 'npm run start',
debug: true,
}
```

@@ -86,3 +70,3 @@

Type: `number`.
Type: `number`, default to `5000`.

@@ -92,7 +76,7 @@ How many milliseconds to wait for the spawned server to be available before giving up.

```javascript
```js
module.exports = {
command: "npm run start",
launchTimeout: 30000,
};
command: 'npm run start',
launchTimeout: 30000,
}
```

@@ -102,3 +86,3 @@

Type: `{}`.
Type: `object`, default to `{}`.

@@ -109,3 +93,3 @@ Any other options to pass to [`spawnd`](https://www.npmjs.com/package/spawnd).

Type: `number`.
Type: `number`, default to `null`.

@@ -115,7 +99,37 @@ Port to wait for activity on before considering the server running.

```javascript
```js
module.exports = {
command: "npm run start --port 3000",
port: 3000,
};
command: 'npm run start --port 3000',
port: 3000,
}
```
#### `usedPortAction`
Type: `string` (`ask`, `error`, `ignore`, `kill`) default to `ask`.
It defines the action to take if port is already used:
- `ask`: a prompt is shown to decide if you want to kill the process or not
- `error`: an errow is thrown
- `ignore`: your test are executed, we assume that the server is already started
- `kill`: the process is automatically killed without a prompt
```js
module.exports = {
command: 'npm run start --port 3000',
port: 3000,
usedPortAction: 'kill',
}
```
## License
MIT
[build-badge]: https://img.shields.io/travis/smooth-code/jest-puppeteer.svg?style=flat-square
[build]: https://travis-ci.org/smooth-code/jest-puppeteer
[version-badge]: https://img.shields.io/npm/v/jest-dev-server.svg?style=flat-square
[package]: https://www.npmjs.com/package/jest-dev-server
[license-badge]: https://img.shields.io/npm/l/jest-dev-server.svg?style=flat-square
[license]: https://github.com/smooth-code/jest-puppeteer/blob/master/LICENSE
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc