test(lib-guards): lib 产物缺失时 chunk-artifact / manifest-consistency 跳过而非 ENOENT
fresh clone 未 build 直接 pnpm test 时,两 spec 的 readFileSync 会 ENOENT 崩溃(此前靠 package.json prepare 钩子隐式兜底)。改为文件级 describe.skipIf 守卫:缺产物时整套显示为 skipped 并 console 提示先 pnpm build(exit 0);产物存在时行为与之前完全一致(本仓 prepare 钩 子产出 lib 后两 spec 照常执行,已验证 9 passed 非 skipped)。
This commit is contained in:
1 parent
936df662b0
commit
0831505854
2 files changed
+22
-4
No files matched your search
@@ -5,8 +5,10 @@
|
||||
* be callable with a require that resolves the platform externals — the
|
||||
* exact shape the loader (src/client/chunk-loader.ts) depends on. Reads the
|
||||
* built lib/ output, so run `pnpm build` first (like manifest-consistency).
|
||||
* A missing lib/ (fresh clone before the first build) skips the whole suite
|
||||
* instead of crashing on ENOENT.
|
||||
*/
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
// Browser globals first: chunk bodies probe `self`/`document` at evaluation
|
||||
// (xterm's UMD wrapper, CodeMirror's UA probe).
|
||||
@@ -17,7 +19,14 @@ const g = globalThis as Record<string, unknown>
|
||||
|
||||
const CHUNKS = ['terminal', 'editor', 'mermaid']
|
||||
|
||||
describe('built chunk artifacts', () => {
|
||||
/** All chunk artifacts present (tsdown emits the whole lib/ in one run). */
|
||||
const chunksBuilt = CHUNKS.every(name => existsSync(`lib/client-${name}.js`))
|
||||
|
||||
if (!chunksBuilt) {
|
||||
console.warn('[chunk-artifact] lib/ chunk artifacts missing — run `pnpm build` first; skipping this suite')
|
||||
}
|
||||
|
||||
describe.skipIf(!chunksBuilt)('built chunk artifacts', () => {
|
||||
it('each chunk assigns its global registry slot when executed as a script', () => {
|
||||
g.window = g // classic-script globals
|
||||
// mermaid's core hooks window.addEventListener('load') at module scope
|
||||
|
||||
Reference in new issue
Block a user