jest-puppeteer icon indicating copy to clipboard operation
jest-puppeteer copied to clipboard

Using createServer.listen() doesn't correctly detect used ports

Open zen0wu opened this issue 6 years ago • 2 comments

🐛 Bug Report

getIsPortTaken function doesn't seem to work correctly under macOS.

To Reproduce

Steps to reproduce the behavior:

  1. nc -l localhost 3000 to start a minimal server locally
  2. Start jest-dev-server on the same port with usedPortAction set to "ask"
  3. It doesn't ask

Expected behavior

It should ask

Link to repl or repo (highly encouraged)

Please provide a minimal repository on GitHub.

Issues without a reproduction link are likely to stall.

Run npx envinfo --system --binaries --npmPackages expect-puppeteer,jest-dev-server,jest-environment-puppeteer,jest-puppeteer,spawnd --markdown --clipboard

Paste the results here:

*** Clipboard option removed - use clipboardy or clipboard-cli directly ***


## System:
 - OS: macOS 10.14.6
 - CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
 - Memory: 1.98 GB / 16.00 GB
 - Shell: 5.7.1 - /usr/local/bin/zsh
## Binaries:
 - Node: 12.10.0 - /usr/local/bin/node
 - Yarn: 1.17.3 - /usr/local/bin/yarn
 - npm: 6.11.3 - /usr/local/bin/npm
 - Watchman: 4.9.0 - /usr/local/bin/watchman
## npmPackages:
 - jest-dev-server: ^4.3.0 => 4.3.0

zen0wu avatar Sep 17 '19 20:09 zen0wu

I'm running into this issue. This bug breaks Jest in VSCode since the local server keeps running and different runs fail all the time.

domoritz avatar Feb 12 '20 21:02 domoritz

~Same issue here, this still seems to be broken~

Should be working, be sure that the port config is set to the correct port:

jest-puppeteer.config.js

module.exports = {
  server: {
    command: `npm start`,
    port: 3000, // if set correctly should work
    usedPortAction: 'ask'
  },
  exitOnPageError: false
}

The getIsPortTaken function checks the provided port by trying to start a server on that specific port. Test configured port by adding: console.log('conigured port:', config.port); at node_modules\jest-dev-server\lib\global.js:173 (using jest-puppeteer v4.4.0)

BitFis avatar Jan 07 '21 10:01 BitFis

Fixed in #518

gregberge avatar Mar 08 '23 12:03 gregberge