Skip to content

Commit 86e0bb2

Browse files
committed
Add tests
1 parent 78127e2 commit 86e0bb2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/tools/pages.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,21 @@ describe('pages', () => {
193193
assert.ok(response.includePages);
194194
});
195195
});
196+
it('navigates to correct page with initScript', async () => {
197+
await withBrowser(async (response, context) => {
198+
await navigatePage.handler(
199+
{params: {url: 'data:text/html,<div>Hello MCP</div>', initScript: 'window.initScript = "completed"'}},
200+
response,
201+
context,
202+
);
203+
const page = context.getSelectedPage();
204+
205+
// wait for up to 1s for the global variable to set by the initScript to exist
206+
await page.waitForFunction("window.initScript==='completed'", {timeout: 1000});
207+
208+
assert.ok(response.includePages);
209+
});
210+
});
196211
});
197212
describe('resize', () => {
198213
it('create a page', async () => {

0 commit comments

Comments
 (0)