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)
This commit is contained in:
parent
1f21a9fb46
commit
c73a2e1caf
1 changed files with 15 additions and 2 deletions
|
|
@ -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}`));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue