Files
pyscript/pyscript.core/test/integration/_shared.js
Andrea Giammarchi 0c54036466 [next] Add basic integrations tests (#1576)
* [next] WIP: Add basic integrations tests

* fix typos in  README.md

* Update README.md to specify when files are _ files ignored

---------

Co-authored-by: Fabio Pliger <fpliger@users.noreply.github.com>
2023-07-19 10:18:17 +02:00

47 lines
1.7 KiB
JavaScript

'use strict';
exports.shared = {
bootstrap: ({ expect }, baseURL) => async ({ page }) => {
await page.goto(`${baseURL}/bootstrap.html`);
await page.waitForSelector('html.ready');
await page.getByRole('button').click();
const result = await page.evaluate(() => document.body.innerText);
await expect(result.trim()).toBe('OK');
},
worker: ({ expect }, url) => async ({ page }) => {
const logs = [];
page.on('console', msg => logs.push(msg.text()));
await page.goto(url);
await page.waitForSelector('html.worker.ready');
await expect(logs.join(',')).toBe('main,thread');
},
workerWindow: ({ expect }, baseURL) => async ({ page }) => {
await page.goto(`${baseURL}/worker-window.html`);
await page.waitForSelector('html.worker.ready');
const result = await page.evaluate(() => document.body.innerText);
await expect(result.trim()).toBe('OK');
},
};
exports.python = {
bootstrap: ({ expect }, baseURL) => async ({ page }) => {
await page.goto(`${baseURL}/bootstrap.html`);
await page.waitForSelector('html.ready');
const result = await page.evaluate(() => document.body.innerText);
await expect(result.trim()).toBe('OK');
},
fetch: ({ expect }, url) => async ({ page }) => {
const logs = [];
page.on('console', msg => logs.push(msg.text()));
await page.goto(url);
await page.waitForSelector('html.ready');
await expect(logs.length).toBe(1);
await expect(logs[0]).toBe('hello from A');
const body = await page.evaluate(() => document.body.innerText);
await expect(body.trim()).toBe('hello from A, hello from B');
},
};