JSPM

  • Created
  • Published
  • Downloads 288243
  • Score
    100M100P100Q168182F
  • License MIT

Creates and tears down a local dev server during Jest tests.

Package Exports

  • jest-dev-server

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jest-dev-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

jest-dev-server

Shamelessly copy & pasted from jest-puppeteer's jest-environment-puppeteer.

Starts a server before your Jest tests and tears it down after. Obeys generally the same settings as as jest-environment-puppeteer.

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

First off, if you're writing tests with Puppeteer, use jest-puppeteer instead.

jest-dev-server exports setupServer and teardownServer functions. setupServer will read in settings from jest-dev-server-config.js.

// globalSetup.js
module.exports = require("jest-dev-server").setupServer;
// globalTeardown.js
module.exports = require("jest-dev-server").teardownServer;
// jest-dev-server.config.js
module.exports = {
    server: {
        command: `node config/start.js --port=3000`,
        port: 3000,
        launchTimeout: 50000,
    },
};