Skip to content

Commit 56635f0

Browse files
committed
test: stabilize weapp-vite watch hmr checks
1 parent 61dcd4b commit 56635f0

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

e2e/watch/hot-update/shared.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,7 @@ export async function runHotUpdateTarget(target: WatchCaseName) {
906906
const cwd = path.resolve(__dirname, '../..')
907907
const timeoutMs = toNumberEnv('E2E_WATCH_TIMEOUT_MS', 240000)
908908
const pollMs = toNumberEnv('E2E_WATCH_POLL_MS', 40)
909+
const maxHotUpdateMs = toNumberEnv('E2E_WATCH_MAX_HOT_UPDATE_MS', timeoutMs)
909910
const maxPluginProcessMs = toNumberEnv('E2E_WATCH_MAX_PLUGIN_PROCESS_MS', DEFAULT_PLUGIN_PROCESS_BUDGET_MS)
910911
const commandTimeoutMs = toNumberEnv(
911912
'E2E_WATCH_COMMAND_TIMEOUT_MS',

scripts/weapp-vite-e2e-watch.mjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import path from 'node:path'
44
import process from 'node:process'
55

66
const READY_RE = /|dev(?:elopment)? server ready|ready in \d+/i
7+
const WEAK_READY_RE = / Vite appType/i
78
const pnpmExecPath = process.env.npm_execpath
89
const sourceDirs = ['miniprogram', 'pages', 'packageA', 'packageB', 'sub-normal', 'sub-independent']
910
const ignoredDirs = new Set(['dist', 'node_modules', '.git'])
@@ -33,11 +34,23 @@ function spawnPnpm(args, options = {}) {
3334
}
3435

3536
function pipeWithReady(child, resolveReady) {
37+
let resolved = false
38+
const resolveOnce = () => {
39+
if (resolved) {
40+
return
41+
}
42+
resolved = true
43+
resolveReady()
44+
}
3645
const onData = (chunk) => {
3746
const text = chunk.toString()
3847
process.stdout.write(text)
3948
if (READY_RE.test(text)) {
40-
resolveReady()
49+
resolveOnce()
50+
return
51+
}
52+
if (WEAK_READY_RE.test(text)) {
53+
resolveOnce()
4154
}
4255
}
4356

0 commit comments

Comments
 (0)