Skip to content

Commit 9867ba2

Browse files
committed
Added E2E test to verify that openapi pages actually load
1 parent 4a73522 commit 9867ba2

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@ublitzjs/preprocess": "github:ublitzjs/preprocess#v0.0.3",
3838
"@ublitzjs/router": "^0.1.0",
3939
"esbuild": "^0.25.9",
40+
"puppeteer": "^24.19.0",
4041
"tsx": "^4.20.5",
4142
"undici": "^7.15.0"
4243
}

tests/index.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {afterAll, describe, it, expect} from "vitest";
22
import {request} from "undici";
33
import {exec} from "node:child_process";
44
import {build} from "esbuild";
5+
import puppeteer from "puppeteer";
6+
import {setTimeout} from "node:timers/promises";
57
var bundledFile = (format:"esm"|"cjs") => "tests/" + format + "/out/test-bundle" + (format == "esm" ? ".mjs" : ".cjs");
68
async function buildExample(format: "esm"|"cjs"){
79
await new Promise((resolve, reject) =>{
@@ -52,12 +54,18 @@ async function buildExample(format: "esm"|"cjs"){
5254
async function suite(serverExports: any, format: "esm" | "cjs"){
5355
await serverExports.start();
5456
afterAll(serverExports.end);
55-
5657
describe(format, ()=>{
57-
it("hello", async ()=>{
58-
await request("http://localhost:" + serverExports.port).then(res=>{
59-
expect(res.statusCode).toBe(404);
58+
it("actually has all ui fetched for openapi", async ()=>{
59+
var browser = await puppeteer.launch();
60+
var page = await browser.newPage();
61+
page.on("pageerror", err => {
62+
console.log(`Page error: ${err.toString()}`);
63+
throw err;
64+
});
65+
await page.goto("http://localhost:" + serverExports.port + "/docs/", {
66+
waitUntil: "networkidle0"
6067
})
68+
await browser.close();
6169
})
6270
});
6371
}

0 commit comments

Comments
 (0)