@tim-code/jest-config-server
v0.3.2
Published
``` npm install @tim-code/jest-config-server ```
Downloads
42
Readme
jest-config-server
npm install @tim-code/jest-config-server
A companion library to server
, this allows the server to be run as part of Jest tests.
Usage
Usage in including project:
// jest.config.js
import config from "@tim-code/jest-config-server"
export default {
...config,
}
Example test
command in package.json
:
"test": "ROUTES_DIR=backend node --no-warnings --experimental-vm-modules node_modules/.bin/jest",
Environment Variables
PORT
: the port to use for the test server; Node randomly assigns an available one by default or if PORT is 0
By using a random port, multiple test suites can run in parallel and there is no worry about asking for a port that is already in use.
ROUTES_DIR
: the directory to provide to the server during global setup
Additionally:
process.env.PORT
is set after the server has been started to the port used to start the server.