From c73a2e1caf15b19f3ee4151211b09e2b4aea84b1 Mon Sep 17 00:00:00 2001 From: Hibryda Date: Wed, 18 Mar 2026 04:06:28 +0100 Subject: [PATCH] fix(e2e): build frontend before tests (prevents wrong-app loading) - onPrepare: run `npm run build` before `cargo tauri build --debug --no-bundle` (--no-bundle skips beforeBuildCommand, leaving no dist/ for the WebView) - SKIP_BUILD: still verify dist/index.html exists, build frontend if missing - Without this fix, the Tauri binary falls back to devUrl and loads whatever app is serving on that port (e.g., BridgeCoach on another project) --- tests/e2e/wdio.conf.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/e2e/wdio.conf.js b/tests/e2e/wdio.conf.js index ecca1b0..395d34a 100644 --- a/tests/e2e/wdio.conf.js +++ b/tests/e2e/wdio.conf.js @@ -120,10 +120,23 @@ export const config = { } if (process.env.SKIP_BUILD) { + // Even with SKIP_BUILD, verify the frontend dist exists + if (!existsSync(resolve(projectRoot, 'dist/index.html'))) { + console.log('Frontend dist/ missing — building frontend only...'); + execSync('npm run build', { cwd: projectRoot, stdio: 'inherit' }); + } console.log('SKIP_BUILD set — using existing debug binary.'); return Promise.resolve(); } - return new Promise((resolve, reject) => { + return new Promise((resolveHook, reject) => { + // Build frontend first (Tauri --no-bundle skips beforeBuildCommand) + console.log('Building frontend...'); + try { + execSync('npm run build', { cwd: projectRoot, stdio: 'inherit' }); + } catch (e) { + reject(new Error(`Frontend build failed: ${e.message}`)); + return; + } console.log('Building Tauri debug binary...'); const build = spawn('cargo', ['tauri', 'build', '--debug', '--no-bundle'], { cwd: projectRoot, @@ -132,7 +145,7 @@ export const config = { build.on('close', (code) => { if (code === 0) { console.log('Debug binary ready.'); - resolve(); + resolveHook(); } else { reject(new Error(`Tauri build failed with exit code ${code}`)); }