Skip to content

Commit

Permalink
fix: fix debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Jun 17, 2018
1 parent 25eebe6 commit 7e395a3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/jest-environment-puppeteer/src/PuppeteerEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const handleError = error => {
process.emit('uncaughtException', error)
}

const KEYS = {
CONTROL_C: '\u0003',
CONTROL_D: '\u0004',
ENTER: '\r',
}

class PuppeteerEnvironment extends NodeEnvironment {
// Jest is not available here, so we have to reverse engineer
// the setTimeout function, see https://github.com/facebook/jest/blob/v23.1.0/packages/jest-runtime/src/index.js#L823
Expand Down Expand Up @@ -63,9 +69,14 @@ class PuppeteerEnvironment extends NodeEnvironment {
return new Promise(resolve => {
const { stdin } = process
const onKeyPress = key => {
if (key === '\r') {
if (
key === KEYS.CONTROL_C ||
key === KEYS.CONTROL_D ||
key === KEYS.ENTER
) {
stdin.removeListener('data', onKeyPress)
if (!listening) {
stdin.setRawMode(false)
stdin.pause()
}
resolve()
Expand Down

0 comments on commit 7e395a3

Please sign in to comment.