Skip to main content

E2E Tests

E2E for uncompiled Dim apps is DimTest’s iframe driver, not Playwright/Cypress as the authoring API. Playwright is only CI glue that opens runTests.html and reads window.__DIM_TEST__.


Registering e2e specs​

DimTest.e2e("iframe counter", async () => {
const page = await DimTest.open("./counter.html", {
ready: "dim-test-counter",
});
await page.click("dim-test-counter");
await page.wait(() => page.text("dim-test-counter").includes("Count: 1"));
});

Specs are also auto-classified as e2e when the script path contains /e2e/ or .e2e.. E2E runs after unit tests. Report layout: Results → Coverage (unit) → E2E.


DimTest.open​

const page = await DimTest.open(url, {
ready: "my-app-root", // optional custom element that must upgrade
cover: true, // default during e2e: instrument notes/** in iframe
mode: "srcdoc", // default: fetch + srcdoc; use "src" to navigate directly
});

Isolation defaults:

  • IndexedDB name suffix (separate from the host page)
  • Session-prefixed localStorage
  • No-op serviceWorker.register

Page object (shadow-piercing): query, queryAll, click, fill, text, wait, close.


Reference layout (dim-boilerplate)​

notes/e2e/
helpers.js # DimE2E.openApp(), shared waits
notes-app.e2e.test.js
notes-crud.e2e.test.js
notes-organize.e2e.test.js
app-shell.e2e.test.js

Helpers typically call DimTest.open("./index.html") against the real app shell. Demo in dim: examples/app-test/ drives counter.html from index.html.


CI with Playwright​

.github/scripts/run-app-tests.mjs (same pattern in dimui):

  1. Serve the repo over HTTP
  2. Chromium opens runTests.html?impl=js (and wasm)
  3. Wait for window.__DIM_TEST__.done
  4. Fail if failed > 0
  5. Optionally enforce 100% unit coverage (e2e coverage is informational)

Playwright is installed only in the Action (npx) — the app still has no bundler.