Jest-puppeteer: Wait for server command

Created on 5 Apr 2018  路  1Comment  路  Source: smooth-code/jest-puppeteer

My jest-puppeteer.config.js is

module.exports = {
  server: {
    command: 'node puppeteer/server-storybook.js',
  },
...

And sometimes I have a network error: tests are trying to reach node process, which is launching, but not completely launched.

Is it possible to tell jest-puppeteer wait until ping localhost:3000 will be ok? Or, at least, tell to wait some amount of milliseconds.

Now I have to set await sleep(1000) before each test suit, which is not convenient.

The problem could be critical in case if you are launching something heavy like webpack-dev-server.

Most helpful comment

It is already possible using port option. See https://github.com/smooth-code/jest-puppeteer#jest-puppeteerconfigjs

I use it in all my projects:

module.exports = {
  launch: {
    headless: process.env.HEADLESS !== 'false',
  },
  server: {
    command: 'yarn babel-node src/server/main.js',
    port: 4444,
  },
}

>All comments

It is already possible using port option. See https://github.com/smooth-code/jest-puppeteer#jest-puppeteerconfigjs

I use it in all my projects:

module.exports = {
  launch: {
    headless: process.env.HEADLESS !== 'false',
  },
  server: {
    command: 'yarn babel-node src/server/main.js',
    port: 4444,
  },
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ifiokjr picture ifiokjr  路  5Comments

xiaoyuhen picture xiaoyuhen  路  5Comments

songguohfut picture songguohfut  路  6Comments

paperbackdragon picture paperbackdragon  路  4Comments

igneel64 picture igneel64  路  5Comments