Skip to content

Commit

Permalink
remove debugging junk
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronWatters committed May 8, 2020
1 parent 113ee1d commit e1cbe15
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Expand Up @@ -13,13 +13,9 @@ before_install:
- sudo apt-get update
- sudo apt-get install python3
- npm install --global http-server
#- python3 start_test_http_server.py &
install:
- npm install
- npm build
script:
#- npm test
- npm run coveralls
#after_success:
#- python3 stop_test_http_server.py
#after_failure:
#- python3 stop_test_http_server.py
15 changes: 8 additions & 7 deletions html/entry.js
Expand Up @@ -8,7 +8,7 @@ if (!global.jQuery) {

require("../dist/index");

//jQuery(function(){
jQuery(function(){
var $ = jQuery;
var y = $("#container");
var z = $('<div>JQuery is working?</div>').appendTo(y);
Expand All @@ -18,10 +18,11 @@ require("../dist/index");
html: "plugin is working",
italic: true
});
//window.js_loaded = true;
ready_for_tests();
//});

// make sure jquery is in the global environment so we can use it in tests
window.jQuery = jQuery;

// Flag that we are ready for testing (observed by end-to-end tests).
window.jQuery.ready_for_tests = true;
});

// put jquery in the global environment so we can use it in tests
window.jQuery = jQuery;
window.jQuery.ready_for_tests = true;
4 changes: 0 additions & 4 deletions jest-puppeteer.config.js
Expand Up @@ -8,8 +8,4 @@ module.exports = {
timeout: 3000000, // 5 minute timeout
args: ["--no-sandbox"], // don't use a sandbox
},
//server: {
// command: 'node server.js',
// port: 4444,
//},
}
2 changes: 2 additions & 0 deletions jest/globalTeardown.js
Expand Up @@ -2,6 +2,8 @@ const { teardown: teardownDevServer } = require('jest-dev-server');
const { teardown: teardownPuppeteer } = require('jest-environment-puppeteer');

module.exports = async function globalTeardown(globalConfig){

// shut down the testing http server.
await teardownDevServer();

await teardownPuppeteer(globalConfig);
Expand Down
15 changes: 8 additions & 7 deletions tests/headless.test.js
Expand Up @@ -49,10 +49,11 @@ describe("headless browser tests", async () => {
await page.goto(url, {waitUntil: 'networkidle2'});
//await jestPuppeteer.debug();
// sleep a second to let the page execute javascript
await sleep(1000);
//await sleep(1000);
//check_truthy("window.test_function");
//await page.waitForFunction(() => !!(window.test_function));
await page.waitForFunction(async () => !!(window.jQuery));
// Wait for the test function to become available.
await page.waitForFunction(async () => !!(window.test_function));
var content = await page.evaluate(async () => window.test_function());
//console.log("function content is: " + content);
var expected_content = "hi there!";
Expand All @@ -68,14 +69,14 @@ describe("headless browser tests", async () => {
await page.goto(url, {waitUntil: 'networkidle2'});
//await jestPuppeteer.debug();
// sleep a second to let the page execute javascript
await sleep(1000);
//await sleep(1000);
//check_truthy("window");
console.log(" js_loaded before: " + await page.evaluate(async () => !!(window.js_loaded)));
console.log(" ... now waiting for window.jQuery ...")
//console.log(" js_loaded before: " + await page.evaluate(async () => !!(window.js_loaded)));
//console.log(" ... now waiting for window.jQuery ...")
await page.waitForFunction(async () => !!(window.jQuery));
console.log(" ... now awaiting window.jQuery.ready_for_tests")
//console.log(" ... now awaiting window.jQuery.ready_for_tests")
await page.waitForFunction(async () => !!(window.jQuery.ready_for_tests));
//await page.waitForFunction(async () => !!(window.js_loaded));
// Validate that the plugin code executed.
var content = await page.evaluate(async () => window.jQuery('#target').text());
//console.log("target content is: " + content);
var expected_content = "plugin is working";
Expand Down

0 comments on commit e1cbe15

Please sign in to comment.