Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ jobs:
- run: yarn install --frozen-lockfile
- run: yarn build
- run: yarn test
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Run E2E tests
run: yarn test:e2e:browser
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
dist
node_modules
test-results
playwright-report
21 changes: 21 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# E2E Tests

- **`e2e/browser/`** — Playwright tests (run in real browser)
- **`e2e/`** — Jest integration tests (NWC faucet, etc., see PR #535)

## Browser tests (Playwright)

Minimal smoke test to verify the bundled SDK loads and runs in a browser.

### Setup

```bash
yarn install
yarn test:e2e:browser:install
```

### Run

```bash
yarn test:e2e:browser
```
26 changes: 26 additions & 0 deletions e2e/browser/fixtures/smoke.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>SDK Smoke Test</title>
</head>
<body>
<div id="status">loading...</div>
<script type="module">
try {
const { SATS, resolveAmount } = await import("/dist/esm/lnclient.js");
const amount = SATS(10);
const resolved = await resolveAmount(amount);
if (resolved.satoshi === 10 && resolved.millisat === 10_000) {
window.__sdkReady = true;
document.getElementById("status").textContent = "ok";
} else {
document.getElementById("status").textContent = "fail";
}
} catch (e) {
console.error(e);
document.getElementById("status").textContent = "error";
}
</script>
</body>
</html>
16 changes: 16 additions & 0 deletions e2e/browser/smoke.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { test, expect } from "@playwright/test";

/**
* Minimal smoke test: verifies the bundled SDK loads and runs in a browser.
* Catches bundle/build issues that Jest (Node) cannot detect.
*/
test("bundled SDK loads and runs in browser", async ({ page }) => {
await page.goto("/e2e/browser/fixtures/smoke.html");
await page.waitForSelector("#status:has-text('ok')", { timeout: 10000 });

const result = await page.evaluate(() => {
return (window as { __sdkReady?: boolean }).__sdkReady;
});

expect(result).toBe(true);
});
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', '/e2e/browser/'],
};
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@
"lint:js": "eslint src --ext .js,.ts --max-warnings 0",
"lint:js:fix": "eslint src --ext .js,.ts --fix",
"tsc:compile": "tsc --noEmit",
"format": "prettier --check '**/*.(md|json)' 'src/**/*.(js|ts)' 'examples/**/*.(js|jsx)'",
"format:fix": "prettier --loglevel silent --write '**/*.(md|json)' 'src/**/*.(js|ts)' 'examples/**/*.(js|jsx|ts)'",
"format": "prettier --check '**/*.(md|json)' 'src/**/*.(js|ts)' 'examples/**/*.(js|jsx)' 'e2e/**/*.(js|ts)' 'playwright.config.ts'",
"format:fix": "prettier --loglevel silent --write '**/*.(md|json)' 'src/**/*.(js|ts)' 'examples/**/*.(js|jsx|ts)' 'e2e/**/*.(js|ts)' 'playwright.config.ts'",
"prepack": "yarn run build",
"test": "jest",
"test:e2e:browser": "playwright test --project=chromium",
"test:e2e:browser:install": "playwright install",
"test:e2e:browser:ui": "playwright test --ui",
"test:e2e:browser:headed": "playwright test --headed",
"clean": "rm -rf dist",
"build": "rollup -c",
"dev": "microbundle watch",
Expand All @@ -67,6 +71,7 @@
"devDependencies": {
"@commitlint/cli": "^20.1.0",
"@commitlint/config-conventional": "^20.0.0",
"@playwright/test": "^1.58.2",
"@rollup/plugin-commonjs": "^28.0.6",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-terser": "^0.4.4",
Expand All @@ -83,6 +88,7 @@
"jest": "^30.0.5",
"lint-staged": "^16.1.4",
"prettier": "^3.6.2",
"serve": "^14.2.4",
"qrcode-terminal": "^0.12.0",
"rollup": "^4.46.2",
"rollup-plugin-dts": "^6.2.1",
Expand Down
25 changes: 25 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
testDir: "./e2e/browser",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: "html",
use: {
baseURL: "http://localhost:3000",
trace: "on-first-retry",
},
projects: [
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
{ name: "firefox", use: { ...devices["Desktop Firefox"] } },
{ name: "webkit", use: { ...devices["Desktop Safari"] } },
],
webServer: {
command: "yarn build && serve . -p 3000",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
timeout: 180000,
},
});
Loading