Skip to content

Commit

Permalink
real aqua test
Browse files Browse the repository at this point in the history
  • Loading branch information
abernier committed Aug 3, 2024
1 parent 7ac878a commit 9084055
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
env:
TURBO_TELEMETRY_DISABLED: 1
TURBO_UI: 0
# TURBO_UI: 0

# Cancel multiple runs when pushing to main
concurrency:
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
#
# Test
#
- run: npm run test -- --filter=@demo/aquarium --env-mode=loose -vvv
- run: npm run test -- --filter=@demo/aquarium
env:
BASE_PATH: ${{ steps.configurepages.outputs.base_path }}

Expand Down
2 changes: 1 addition & 1 deletion demos/aquarium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build": "tsc && vite build",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview",
"test": "exit 0"
"test": "e2e-test $npm_package_name"
},
"browserslist": [
">0.2%",
Expand Down
22 changes: 19 additions & 3 deletions packages/e2e/bin/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ const updateSnapshots = argv["update-snapshots"];
let vite;
let playwright;

function startVite(base = "/") {
function startVite(base = "/", timeout = 30000) {
return new Promise((resolve, reject) => {
const proc = spawn("npx", ["vite", "preview", "--host", "--base", base]);

const timeoutId = setTimeout(() => {
proc.kill();
reject(new Error("Vite has timed out"));
}, timeout);

//
// Look for the port number in the output, eg:
//
Expand All @@ -35,11 +40,19 @@ function startVite(base = "/") {
//
proc.stdout.on("data", (data) => {
const output = data.toString();
const urlMatch = output.match(/Local: +(\S+)/);
console.log(output);

const urlMatch = output.match(/Local:\s+(http:\/\/[^\s]+)/);
console.log("urlMatch=", urlMatch);

if (urlMatch) {
clearTimeout(timeoutId);
resolve({ vite: proc, url: urlMatch[1] });
}
});
proc.stderr.on("data", (data) => {
console.error(data.toString());
});

proc.on("exit", (code) => {
console.log("exiting vite", code);
Expand All @@ -48,7 +61,10 @@ function startVite(base = "/") {
console.log("closing vite", code);
});

proc.on("error", reject);
proc.on("error", (error) => {
clearTimeout(timeoutId);
reject(error);
});
});
}

Expand Down

0 comments on commit 9084055

Please sign in to comment.