Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: faster tests #163

Merged
merged 1 commit into from
Jun 21, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- name: Run Checker
run: pnpm run check
- name: Run tests
run: pnpm run test
run: pnpm run test -c
57 changes: 57 additions & 0 deletions examples/ciTest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"order": [
"add",
"movement",
"collision",
"gravity",
"sprite",
"fadeIn",
"text",
"audio",
"level",
"scenes",
"timer",
"component",
"layer",
"layers",
"query",
"camera",
"ai",
"loader",
"button",
"dialog",
"draw",
"shader",
"children",
"concert",
"doublejump",
"drag",
"hover",
"largeTexture",
"maze",
"mazeRaycastedLight",
"multiboom",
"multigamepad",
"out",
"overlap",
"pauseMenu",
"polygon",
"polygonuv",
"linecap",
"linejoin",
"postEffect",
"rect",
"transformShape",
"raycastShape",
"raycastObject",
"curves",
"size",
"slice9",
"spriteatlas",
"tween",
"easing",
"bench",
"gamepad",
"binding"
]
}
23 changes: 18 additions & 5 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import fs from "fs/promises";
import path from "path";
import puppeteer from "puppeteer";
import { build, serve, wait } from "./lib.js";
const exampleCI = JSON.parse(
await fs.readFile(
new URL('../examples/ciTest.json', import.meta.url)
)
);

await build();
const port = process.env.PORT || 8001;
Expand All @@ -11,12 +16,20 @@ let failed = false;
console.log("launching browser");
const browser = await puppeteer.launch();
console.log("getting examples list");
const examples = (await fs.readdir("examples"))
.filter((p) => !p.startsWith(".") && p.endsWith(".js"))
.map((d) => path.basename(d, ".js"))
// particle example crashes puppeteer in github action for some reason
.filter((e) => e !== "particle");
let examples

if (process.argv[2] === "--ci" || process.argv[2] === "-c") {
console.log("Testing For Github CI");
examples = exampleCI.order;
}
else{
console.log("Testing For Local Development");
examples = (await fs.readdir("examples"))
.filter((p) => !p.startsWith(".") && p.endsWith(".js"))
.map((d) => path.basename(d, ".js"))
// particle example crashes puppeteer in github action for some reason
.filter((e) => e !== "particle");
}
for (const example of examples) {
console.log(`testing example "${example}"`);
const page = await browser.newPage();
Expand Down