test(ses-integration-test): Lower flaps
Prior to this change, the integration tests concluded upon rendering a
page title, which was occasionally but rarely too soon for the tests to
finish running.
This change alters the script to wait for the test conclusion as
reported in TAP format.
Fixes
MODIFY
packages/ses-integration-test/puppeteer-test/utility/test-bundler.js
packages/ses-integration-test/puppeteer-test/utility/test-bundler.js
@@ -3,16 +3,19 @@ import test from 'tape-promise/tape';
import path from 'path';
-const runBrowserTests = async indexFile => {
+const runBrowserTests = async (t, indexFile) => {
const browser = await puppeteer.launch();
- const page = await browser.newPage();
- page.on('pageerror', err => {
- console.log(err);
- });
let numTests;
let numPass;
+
+ const page = await browser.newPage();
+
+ const done = new Promise((resolve, reject) => {
+ page.on('pageerror', reject);
+
page.on('console', msg => {
+ console.log('>>> ', msg.text());
if (msg.text().includes('# tests')) {
[numTests] = msg
.text()
@@ -25,16 +28,36 @@ const runBrowserTests = async indexFile => {
.split(' ')
.slice(-1);
}
+ if (msg.text().includes('# fail')) {
+ reject(new Error(`At least one test failed for ${indexFile}`));
+ }
+ if (msg.text().includes('# ok')) {
+ resolve();
+ }
});
- await page.goto(`file:${path.join(__dirname, indexFile)}`);
- await page.title();
+ });
+
+ try {
+ await Promise.race([
+ done,
+ page.goto(`file:${path.join(__dirname, indexFile)}`),
+ ]);
+
+ await done;
+ } finally {
await browser.close();
+ }
+
+ if (numTests === undefined) {
+ t.fail('No test results reported');
+ }
+
return { numTests, numPass };
};
const testBundler = (bundlerName, indexFile) => {
test(`SES works with ${bundlerName}`, t => {
- runBrowserTests(indexFile)
+ runBrowserTests(t, indexFile)
.then(({ numTests, numPass }) => {
t.notEqual(numTests, undefined);
t.equal(numTests, numPass);

test(ses-integration-test): Lower flaps

Prior to this change, the integration tests concluded upon rendering a
page title, which was occasionally but rarely too soon for the tests to
finish running.
This change alters the script to wait for the test conclusion as
reported in TAP format.

Fixes #688