mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 10:17:23 -05:00
* Fix #1899 - Expose pyscript.js_modules as module * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix #1899 - Make import as smooth as in polyscript --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
import { test, expect } from '@playwright/test';
|
|
|
|
test('MicroPython display', async ({ page }) => {
|
|
await page.goto('http://localhost:8080/test/mpy.html');
|
|
await page.waitForSelector('html.done.worker');
|
|
const body = await page.evaluate(() => document.body.innerText);
|
|
await expect(body.trim()).toBe([
|
|
'M-PyScript Main 1',
|
|
'M-PyScript Main 2',
|
|
'M-PyScript Worker',
|
|
].join('\n'));
|
|
});
|
|
|
|
test('MicroPython hooks', async ({ page }) => {
|
|
const logs = [];
|
|
page.on('console', msg => {
|
|
const text = msg.text();
|
|
if (!text.startsWith('['))
|
|
logs.push(text);
|
|
});
|
|
await page.goto('http://localhost:8080/test/hooks.html');
|
|
await page.waitForSelector('html.done.worker');
|
|
await expect(logs.join('\n')).toBe([
|
|
'main onReady',
|
|
'main onBeforeRun',
|
|
'main codeBeforeRun',
|
|
'actual code in main',
|
|
'main codeAfterRun',
|
|
'main onAfterRun',
|
|
'worker onReady',
|
|
'worker onBeforeRun',
|
|
'worker codeBeforeRun',
|
|
'actual code in worker',
|
|
'worker codeAfterRun',
|
|
'worker onAfterRun',
|
|
].join('\n'));
|
|
});
|
|
|
|
test('MicroPython + Pyodide js_modules', async ({ page }) => {
|
|
const logs = [];
|
|
page.on('console', msg => {
|
|
const text = msg.text();
|
|
if (!text.startsWith('['))
|
|
logs.push(text);
|
|
});
|
|
await page.goto('http://localhost:8080/test/js_modules.html');
|
|
await page.waitForSelector('html.done');
|
|
await expect(logs.length).toBe(6);
|
|
await expect(logs[0]).toBe(logs[1]);
|
|
await expect(logs[1]).toBe(logs[2]);
|
|
await expect(logs[3]).toBe(logs[4]);
|
|
await expect(logs[4]).toBe(logs[5]);
|
|
});
|