Skip to content

Commit 98b9e55

Browse files
committed
Fix flakey test
Sometimes the “HTML tab is hidden” was running before the page was ready for testing. This fixes the issue by running a test beforehand that waits until the page has loaded.
1 parent fd611f2 commit 98b9e55

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,28 @@ describe("bit-docs-tag-demo", function() {
298298
});
299299

300300
describe("HTML", function() {
301+
it("exists on page", function() {
302+
return ctx.page
303+
.waitForFunction(function() {
304+
return !!window.PACKAGES;
305+
})
306+
.then(function() {
307+
return ctx.page.evaluate(function() {
308+
return {
309+
hasPackages: !!window.PACKAGES,
310+
hasWrapper: !!document.querySelectorAll(".demo_wrapper").length,
311+
wasInjected: !!document.querySelectorAll(".demo_wrapper .demo")
312+
.length
313+
};
314+
});
315+
})
316+
.then(function(r) {
317+
assert(r.hasPackages, "has global PACKAGES");
318+
assert(r.hasWrapper, "wrapper exists");
319+
assert(r.wasInjected, "injected into wrapper");
320+
});
321+
});
322+
301323
// expect no content
302324
dataForHtml("");
303325

0 commit comments

Comments
 (0)