Socket
Socket
Sign inDemoInstall

jest-dev-server

Package Overview
Dependencies
63
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jest-dev-server

Starts a server before your Jest tests and tears it down after.


Version published
Weekly downloads
244K
increased by7.07%
Maintainers
2
Install size
7.94 MB
Created
Weekly downloads
 

Changelog

Source

3.2.0 (2018-06-17)

Bug Fixes

  • jest-dev-server: fix watch mode stdin after ask (a7ca57b)

Features

<a name="3.1.0"></a>

Readme

Source

jest-dev-server

Starts a server before your Jest tests and tears it down after.

Why

jest-puppeteer works great for running tests in Jest using Puppeteer. It's also useful for starting a local development server during the tests without letting Jest hang. This package extracts just the local development server spawning without any ties to Puppeteer.

Usage

jest-dev-server exports setup and teardown functions.

// global-setup.js
const { setup: setupDevServer } = require('jest-dev-server')

module.exports = async function globalSetup() {
  await setupDevServer({
    command: `node config/start.js --port=3000`,
    launchTimeout: 50000,
    port: 3000,
  })
  // Your global setup
}
// global-teardown.js
const { setup: teardownDevServer } = require('jest-dev-server')

module.exports = async function globalTeardown() {
  await teardownDevServer()
  // Your global teardown
}
Options
command

Type: string, required.

Command to execute to start the port. Directly passed to spawnd.

module.exports = {
  command: 'npm run start',
}
debug

Type: boolean, default to false.

Log server output, useful if server is crashing at start.

module.exports = {
  command: 'npm run start',
  debug: true,
}
launchTimeout

Type: number, default to 5000.

How many milliseconds to wait for the spawned server to be available before giving up. Defaults to wait-port's default.

module.exports = {
  command: 'npm run start',
  launchTimeout: 30000,
}
options

Type: object, default to {}.

Any other options to pass to spawnd.

port

Type: number, default to null.

Port to wait for activity on before considering the server running. If not provided, the server is assumed to immediately be running.

module.exports = {
  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
module.exports = {
  command: 'npm run start --port 3000',
  port: 3000,
  usedPortAction: 'kill',
}

License

MIT

Keywords

FAQs

Last updated on 17 Jun 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc