Skip to content

Commit

Permalink
[CLEANUP beta] emberjs#16391 Cleaning up the test output
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecoy committed Apr 9, 2018
1 parent 0644606 commit c11e447
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions bin/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var path = require('path');
var finalhandler = require('finalhandler');
var http = require('http');
var serveStatic = require('serve-static');
var puppeteer = require('puppeteer');

// Serve up public/ftp folder.
var serve = serveStatic('./dist/', { index: ['index.html', 'index.htm'] });
Expand All @@ -28,6 +29,9 @@ var PORT = 13141;
// Listen.
server.listen(PORT);

// Cache the Chrome browser instance when launched for new pages.
var browserPromise;

function run(queryString) {
return new RSVP.Promise(function(resolve, reject) {
var url = 'http://localhost:' + PORT + '/tests/?' + queryString;
Expand All @@ -40,9 +44,11 @@ function runInBrowser(url, retries, resolve, reject) {

console.log('Running Chrome headless: ' + url);

var puppeteer = require('puppeteer');
if (!browserPromise) {
browserPromise = puppeteer.launch();
}

puppeteer.launch().then(function(browser) {
browserPromise.then(function(browser) {
browser.newPage().then(function(page) {
/* globals window */
var crashed;
Expand Down Expand Up @@ -136,17 +142,17 @@ function runInBrowser(url, retries, resolve, reject) {
' failed.'
);

if (typeof window.callPhantom === 'function') {
window.callPhantom({
name: 'QUnit.done',
data: result,
});
}
window.callPhantom({
name: 'QUnit.done',
data: result,
});
});
});
};

page.exposeFunction('callPhantom', function(message) {
page.close();

if (message && message.name === 'QUnit.done') {
result = message.data;
var failed = !result || !result.total || result.failed;
Expand Down Expand Up @@ -177,11 +183,11 @@ function runInBrowser(url, retries, resolve, reject) {
reject(result);
}
}
}).then(function() {
return page.evaluateOnNewDocument(addLogging);
}).then(function() {
page.goto(url, { timeout: 900 });
});

page.evaluateOnNewDocument(addLogging);

page.goto(url, { timeout: 900 });
});
});
}
Expand Down

0 comments on commit c11e447

Please sign in to comment.