Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

Implement a fix to clear out the old queue so users can catch errors #311

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ export default class Queue {
this.lastWaitAll = this.waitAll()
}

await this.lastWaitAll
const currentWaitAll = this.lastWaitAll
try {
await this.lastWaitAll
} finally {
if (this.lastWaitAll == currentWaitAll) {
this.lastWaitAll = null;
}
}

return this.chrome.process<T>(command)
}
Expand Down
16 changes: 16 additions & 0 deletions src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,19 @@ test('screenshot by selector', async t => {
t.is(png.width, versionMajor > 60 ? 512 : 1440)
t.is(png.height, versionMajor > 60 ? 512 : 900)
})

test('queue allows actions after an error', async t => {
const chromeless = new Chromeless({ launchChrome: false })
const error = await chromeless
.goto(testUrl)
.wait('.non-existant-selector', 100)
.screenshot()
.catch(error => error)

await error

const screenshot = await chromeless.screenshot();

const regex = new RegExp(os.tmpdir().replace(/\\/g, '\\\\'))
t.regex(screenshot, regex)
})