Skip to content

Commit

Permalink
fix: add missing operators preventing the wait option to work (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisfontaine committed Dec 20, 2020
1 parent 6873117 commit f253235
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ async function getHTML(browser: Browser, options: TakiOptions) {
let result: Result | undefined
if (options.manually) {
result = await promise
} else if (options.wait === 'number') {
} else if (typeof options.wait === 'number') {
await page.waitFor(options.wait)
} else if (options.wait === 'string') {
} else if (typeof options.wait === 'string') {
await page.waitForSelector(options.wait)
}
content = result ? result.content : await page.content()
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test.before(async () => {
server.listen(port)
})

test.after(async () => {
test.after.always(async () => {
server && server.close()
await cleanup()
})
Expand Down
6 changes: 3 additions & 3 deletions test/server/wait-for-selector.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script>
setTimeout(() => {
document.write('foo')
window.snapshot && window.snapshot()
}, 200)
window?.snapshot()
})

setTimeout(() => {
const el = document.createElement('div')
el.id = 'bar'
el.textContent = 'bar'
document.body.appendChild(el)
}, 400)
}, 2000)
</script>

0 comments on commit f253235

Please sign in to comment.