How to use jest-dev-server - 7 common examples

To help you get started, we’ve selected a few jest-dev-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs-shipyard / ipfs-webui / test / e2e / setup / global-init.js View on Github external
module.exports = async function globalSetup (globalConfig) {
  // global setup first
  await setupPuppeteer(globalConfig)
  // http server with webui build
  await setupDevServer({
    command: `ecstatic build --cache=0 --port=${webuiPort}`,
    launchTimeout: 10000,
    port: webuiPort,
    debug: process.env.DEBUG === 'true'
  })
  const endpoint = process.env.E2E_API_URL
  let ipfsd
  let ipfs
  if (endpoint) {
    // create http client for endpoint passed via E2E_API_URL=
    ipfs = ipfsClient({ apiAddr: endpoint })
  } else {
    // use ipfds-ctl to spawn daemon to expose http api used for e2e tests
    const type = process.env.E2E_IPFSD_TYPE || 'go'
    const factory = Ctl.createFactory({
      type,
github ipfs-shipyard / ipfs-webui / test / e2e / setup / global-teardown.js View on Github external
module.exports = async function globalTeardown (globalConfig) {
  const teardown = []
  // custom teardown
  const ipfsd = global.__IPFSD__
  if (ipfsd) teardown.push(ipfsd.stop())
  // continue with global teardown
  teardown.push(teardownDevServer())
  teardown.push(teardownPuppeteer(globalConfig))
  await Promise.all(teardown)
}
github smooth-code / jest-puppeteer / packages / jest-environment-puppeteer / src / global.js View on Github external
if (config.connect) {
    browser = await puppeteer.connect(config.connect)
  } else {
    browser = await puppeteer.launch(config.launch)
  }
  process.env.PUPPETEER_WS_ENDPOINT = browser.wsEndpoint()

  // If we are in watch mode, - only setupServer() once.
  if (jestConfig.watch || jestConfig.watchAll) {
    if (didAlreadyRunInWatchMode) return
    didAlreadyRunInWatchMode = true
  }

  if (config.server) {
    try {
      await setupServer(config.server)
    } catch (error) {
      if (error.code === ERROR_TIMEOUT) {
        console.log('')
        console.error(chalk.red(error.message))
        console.error(
          chalk.blue(
            `\n☝️ You can set "server.launchTimeout" in jest-puppeteer.config.js`,
          ),
        )
        process.exit(1)
      }
      if (error.code === ERROR_NO_COMMAND) {
        console.log('')
        console.error(chalk.red(error.message))
        console.error(
          chalk.blue(
github charliewilco / downwrite / integration / config / setup.js View on Github external
module.exports = async function globalSetup() {
  await setupDevServer({
    command: `yarn workspaces run dev`,
    launchTimeout: 50000,
    port: 7000
  });
  // Your global setup
};
github ifiokjr / remirror / support / jest / puppeteer.ts View on Github external
export async function setupServer(globalConfig: Config.GlobalConfig) {
  await setup([server]);

  onExit(() =>
    Promise.all([teardown(), teardownPuppeteer()]).then(() => {
      process.exit();
    }),
  );

  await setupPuppeteer(globalConfig);
}
github ifiokjr / remirror / support / jest / puppeteer.ts View on Github external
export async function destroyServer(globalConfig: Config.GlobalConfig) {
  serverSetupPromise = undefined;
  await teardown();
  await teardownPuppeteer(globalConfig);
}
github smooth-code / jest-puppeteer / packages / jest-environment-puppeteer / src / global.js View on Github external
export async function teardown(jestConfig = {}) {
  const config = await readConfig()

  if (config.connect) {
    await browser.disconnect()
  } else {
    await browser.close()
  }

  if (!jestConfig.watch && !jestConfig.watchAll) {
    await teardownServer()
  }
}

jest-dev-server

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

MIT
Latest version published 27 days ago

Package Health Score

92 / 100
Full package analysis

Popular jest-dev-server functions