Skip to content

Commit 76cf769

Browse files
authored
Report browser test errors (#5408)
1 parent 44bf599 commit 76cf769

File tree

1 file changed

+22
-34
lines changed

1 file changed

+22
-34
lines changed

Cakefile

+22-34
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,6 @@ task 'test', 'run the CoffeeScript language test suite', ->
499499

500500

501501
task 'test:browser', 'run the test suite against the modern browser compiler in a headless browser', ->
502-
# This test uses Puppeteer to launch headless Chrome to test the ES module
503-
# version of the browser compiler. There’s no reason to run this test in old
504-
# versions of Node (the runtime is the headless Chrome browser, not Node),
505-
# and Puppeteer 3 only supports Node >= 10.18.1, so limit this test to those
506-
# versions. The code below uses `Promise.prototype.finally` because the
507-
# CoffeeScript codebase currently maintains compatibility with Node 6, which
508-
# did not support `async`/`await` syntax. Even though this test doesn’t run
509-
# in Node 6, it needs to still _parse_ in Node 6 so that this file can load.
510-
[major, minor, build] = process.versions.node.split('.').map (n) -> parseInt(n, 10)
511-
return if major < 10 or (major is 10 and minor < 18) or (major is 10 and minor is 18 and build < 1)
512-
513502
# Create very simple web server to serve the two files we need.
514503
http = require 'http'
515504
serveFile = (res, fileToServe, mimeType) ->
@@ -526,29 +515,28 @@ task 'test:browser', 'run the test suite against the modern browser compiler in
526515
else
527516
res.statusCode = 404
528517
res.end()
529-
server.listen 8080
530-
531-
puppeteer = require 'puppeteer'
532-
browser = page = result = null
533-
puppeteer.launch()
534-
.then((browserHandle) ->
535-
browser = browserHandle
536-
browser.newPage()
537-
).then((pageHandle) ->
538-
page = pageHandle
539-
page.goto 'http://localhost:8080/'
540-
).then(->
541-
page.waitForSelector '#result',
542-
visible: yes
543-
polling: 'mutation'
544-
).then((element) ->
545-
page.evaluate ((el) => el.textContent), element
546-
).then((elementText) ->
547-
result = elementText
548-
).finally(->
549-
browser.close()
550-
).finally ->
551-
server.close()
518+
519+
server.listen 8080, ->
520+
puppeteer = require 'puppeteer'
521+
browser = await puppeteer.launch()
522+
page = await browser.newPage()
523+
result = ""
524+
525+
try
526+
await page.goto 'http://localhost:8080/'
527+
528+
element = await page.waitForSelector '#result',
529+
visible: yes
530+
polling: 'mutation'
531+
timeout: 60000
532+
533+
result = await page.evaluate ((el) => el.textContent), element
534+
catch e
535+
log e, red
536+
finally
537+
try browser.close()
538+
server.close()
539+
552540
if result and not result.includes('failed')
553541
log result, green
554542
else

0 commit comments

Comments
 (0)