Skip to content

Commit

Permalink
Added some diagnostic output on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed May 29, 2018
1 parent 3646201 commit 89dba09
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions test/es2015/check-esm-bundle-is-runnable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const htmlWithModuleScript = `
<script type="module">
import sinon from '/sinon-esm.js';
const assert = (result) => { if(!result) throw new Error(); };
const assert = (result) => { if(!result) throw new Error("Failed test"); };
try {
const stub = sinon.stub().returns(42);
assert(42 === stub());
console.log('sinon-result:works');
} catch(err) {
console.log('sinon-result:fails');
console.log('sinon-result:fails Assertion incorrect' );
}
</script>
`;
Expand All @@ -30,6 +30,16 @@ async function evaluatePageContent() {
const browser = await puppeteer.launch({ args: ["--no-sandbox"] });
const page = await browser.newPage();

function die(reason) {
if (reason) {
/* eslint-disable no-console */
console.error(reason);
}

browser.close();
process.exit(1);
}

page.on("error", function (err) {
throw err;
});
Expand All @@ -42,12 +52,13 @@ async function evaluatePageContent() {
browser.close();
process.exit(0);
} else if (text.startsWith("sinon-result:fails")) {
browser.close();
process.exit(1);
die(text);
}
});

await page.goto("http://localhost:3876");

setTimeout(() => die("No result within timeout."), 1000);
}

const app = http.createServer((req, res) => {
Expand Down

0 comments on commit 89dba09

Please sign in to comment.