Skip to content

Commit

Permalink
see if travis can call the test function
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronWatters committed May 7, 2020
1 parent d57d22a commit d1e8f3b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 4 additions & 1 deletion html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ <h1>Test page</h1>

<script>
window.js_loaded = false;

function test_function() {
return "hi there!";
};
</script>

<script src="bundle.js"></script>


<script>
window.js_loaded = true;
</script>
Expand Down
19 changes: 18 additions & 1 deletion tests/headless.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ describe("headless browser tests", async () => {
});
};

it("calls the test function", async () => {
//await jestPuppeteer.debug();
const page = await browser.newPage();
const url = "http://127.0.0.1:3000/html/index.html";
await page.goto(url);
//await jestPuppeteer.debug();
// sleep a second to let the page execute javascript
await sleep(1000);
await page.waitForFunction("window.js_loaded");
var content = await page.evaluate("test_function()");
console.log("function content is: " + content);
var expected_content = "hi there!";
expect(content).toBe(expected_content);
},
120000, // timeout in 2 minutes...
);

it("sets the html using the plugin", async () => {
//await jestPuppeteer.debug();
const page = await browser.newPage();
Expand All @@ -45,7 +62,7 @@ describe("headless browser tests", async () => {
console.log("window is defined? " + wqd);
var jsld = await page.evaluate(() => window.js_loaded);
console.log("js_loaded gets: " + jsld);
//return;
return;
await page.waitForFunction("window.js_loaded");
var content = await page.evaluate("jQuery('#target').html()");
console.log("target content is: " + content);
Expand Down

0 comments on commit d1e8f3b

Please sign in to comment.