jest-dev-server
Advanced tools
Comparing version 0.1.2 to 3.1.0
{ | ||
"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" | ||
} | ||
} |
132
README.md
# 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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
130
2
10801
7
6
130
1
2
+ Addedchalk@^2.4.1
+ Addedfind-process@^1.1.1
+ Addedinquirer@^6.0.0
+ Addedterminate@^2.1.0
+ Addedansi-escapes@3.2.0(transitive)
+ Addedansi-regex@3.0.14.1.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchardet@0.7.0(transitive)
+ Addedcli-cursor@2.1.0(transitive)
+ Addedcli-width@2.2.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommander@5.1.0(transitive)
+ Addedexternal-editor@3.1.0(transitive)
+ Addedfigures@2.0.0(transitive)
+ Addedfind-process@1.4.7(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinquirer@6.5.2(transitive)
+ Addedis-fullwidth-code-point@2.0.0(transitive)
+ Addedmimic-fn@1.2.0(transitive)
+ Addedmute-stream@0.0.7(transitive)
+ Addedonetime@2.0.1(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedrestore-cursor@2.0.0(transitive)
+ Addedrun-async@2.4.1(transitive)
+ Addedrxjs@6.6.7(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedstring-width@2.1.1(transitive)
+ Addedstrip-ansi@4.0.05.2.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtmp@0.0.33(transitive)
+ Addedtslib@1.14.1(transitive)
- Removedlodash@^4.17.10
- Removedmz@^2.7.0
- Removedportscanner@^2.2.0
- Removedany-promise@1.3.0(transitive)
- Removedasync@2.6.4(transitive)
- Removedis-number-like@1.0.8(transitive)
- Removedlodash.isfinite@3.3.2(transitive)
- Removedmz@2.7.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedportscanner@2.2.0(transitive)
- Removedthenify@3.3.1(transitive)
- Removedthenify-all@1.6.0(transitive)