Skip to content

Commit

Permalink
Create dynamic element for puppeteer to wait on
Browse files Browse the repository at this point in the history
  • Loading branch information
bidoubiwa committed Oct 27, 2020
1 parent 3ba930d commit 14c23fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/env/express/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</head>
<body>
Index name:
<div id="indexes"></div>
<div id="content"></div>
</body>
</html>
<script src="./meilisearch.umd.js"></script>
Expand All @@ -21,8 +21,13 @@
})
await client.getOrCreateIndex("createdIndexTest")
const index = await client.getIndex("createdIndexTest").show()
document.querySelector('#indexes').innerHTML = `<div>${JSON.stringify(index.uid)}</div>`
await client.getIndex("test").deleteIndex()
// Create dynamic element to wait on with puppeteer
const newDiv = document.createElement("div");
newDiv.setAttribute("id", "indexes");
newDiv.innerHTML = index.uid

document.body.insertBefore(newDiv, document.querySelector("#content"));
await client.getIndex("createdIndexTest").deleteIndex()
} catch(e) {
console.error(e);
}
Expand Down
1 change: 1 addition & 0 deletions tests/env/express/tests/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ describe('MeiliSearch JS Browser test', () => {
})

it('Should have generated a meilisearch client and displayed', async () => {
await page.waitForSelector("#indexes")
await expect(
page.content()
).resolves.toMatch('createdIndexTest')
Expand Down

0 comments on commit 14c23fd

Please sign in to comment.