mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Replace PhantomJS in Test in Console Runner
Replace Test In Console PhantomJS with Puppeteer. Update Travis node to current Meteor version for compatibility with Puppeteer.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "4.0"
|
||||
- "8.11.1"
|
||||
cache:
|
||||
directories:
|
||||
- ".meteor"
|
||||
|
||||
@@ -7,6 +7,10 @@ export METEOR_HOME=`pwd`
|
||||
# Just in case these packages haven't been installed elsewhere.
|
||||
./meteor npm install -g phantomjs-prebuilt browserstack-webdriver
|
||||
|
||||
# Install locally
|
||||
./meteor npm install puppeteer@1.3.0
|
||||
|
||||
|
||||
export PATH=$METEOR_HOME:$PATH
|
||||
# synchronously get the dev bundle and NPM modules if they're not there.
|
||||
./meteor --help || exit 1
|
||||
@@ -17,8 +21,8 @@ exec 3< <(meteor test-packages --driver-package test-in-console -p 4096 --exclud
|
||||
EXEC_PID=$!
|
||||
|
||||
sed '/test-in-console listening$/q' <&3
|
||||
./dev_bundle/bin/phantomjs "$METEOR_HOME/packages/test-in-console/runner.js"
|
||||
node "$METEOR_HOME/packages/test-in-console/runner.js"
|
||||
STATUS=$?
|
||||
|
||||
pkill -TERM -P $EXEC_PID
|
||||
exit $STATUS
|
||||
exit $STATUS
|
||||
@@ -1,37 +1,30 @@
|
||||
var createPage = require("webpage").create;
|
||||
var system = require("system");
|
||||
var platform = system.args[1] || "local";
|
||||
var platformUrl = system.env.URL + platform;
|
||||
var testUrls = [
|
||||
// Additional application URLs can be added here to re-run tests in
|
||||
// PhantomJS with different query parameter-based configurations.
|
||||
platformUrl,
|
||||
];
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
function runNextUrl() {
|
||||
var url = testUrls.shift();
|
||||
if (! url) {
|
||||
phantom.exit(0);
|
||||
async function runNextUrl(browser) {
|
||||
const page = await browser.newPage();
|
||||
|
||||
page.on('console', msg => {
|
||||
console.log(msg._text);
|
||||
});
|
||||
|
||||
if (!process.env.URL) {
|
||||
await page.close();
|
||||
await browser.close();
|
||||
process.exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Running Meteor tests in PhantomJS... " + url);
|
||||
await page.goto(process.env.URL);
|
||||
|
||||
var page = createPage();
|
||||
|
||||
page.onConsoleMessage = function (message) {
|
||||
console.log(message);
|
||||
};
|
||||
|
||||
page.open(url);
|
||||
|
||||
function poll() {
|
||||
if (isDone(page)) {
|
||||
var failCount = getFailCount(page);
|
||||
async function poll() {
|
||||
if (await isDone(page)) {
|
||||
let failCount = await getFailCount(page);
|
||||
if (failCount > 0) {
|
||||
phantom.exit(1);
|
||||
await page.close();
|
||||
await browser.close();
|
||||
process.exit(1);
|
||||
} else {
|
||||
page.close();
|
||||
await page.close();
|
||||
setTimeout(runNextUrl, 1000);
|
||||
}
|
||||
} else {
|
||||
@@ -42,23 +35,23 @@ function runNextUrl() {
|
||||
poll();
|
||||
}
|
||||
|
||||
function isDone(page) {
|
||||
return page.evaluate(function () {
|
||||
if (typeof TEST_STATUS !== "undefined") {
|
||||
async function isDone(page) {
|
||||
return await page.evaluate(function() {
|
||||
if (typeof TEST_STATUS !== 'undefined') {
|
||||
return TEST_STATUS.DONE;
|
||||
}
|
||||
|
||||
return typeof DONE !== "undefined" && DONE;
|
||||
return typeof DONE !== 'undefined' && DONE;
|
||||
});
|
||||
}
|
||||
|
||||
function getFailCount(page) {
|
||||
return page.evaluate(function () {
|
||||
if (typeof TEST_STATUS !== "undefined") {
|
||||
async function getFailCount(page) {
|
||||
return await page.evaluate(function() {
|
||||
if (typeof TEST_STATUS !== 'undefined') {
|
||||
return TEST_STATUS.FAILURES;
|
||||
}
|
||||
|
||||
if (typeof FAILURES === "undefined") {
|
||||
if (typeof FAILURES === 'undefined') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -66,4 +59,13 @@ function getFailCount(page) {
|
||||
});
|
||||
}
|
||||
|
||||
runNextUrl();
|
||||
async function runTests() {
|
||||
console.log(`Running test with Puppeteer at ${process.env.URL}`);
|
||||
|
||||
// --no-sandbox and --disable-setuid-sandbox must be disabled for CI compatibility
|
||||
const browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] });
|
||||
console.log(`Using version: ${await browser.version()}`);
|
||||
runNextUrl(browser);
|
||||
}
|
||||
|
||||
runTests();
|
||||
|
||||
Reference in New Issue
Block a user