import assert from 'node:assert/strict'; import { execFileSync } from 'node:child_process'; import { readFile } from 'node:fs/promises'; import { test } from 'node:test'; import { fileURLToPath } from 'node:url'; import { dirname, resolve } from 'node:path'; const mobileRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..'); const readJson = async (path) => JSON.parse(await readFile(new URL(path, import.meta.url), 'utf8')); test('App 图标与启动图映射均可由预检脚本验证', () => { const output = execFileSync(process.execPath, ['scripts/verify-app-assets.mjs'], { cwd: mobileRoot, encoding: 'utf8' }); assert.match(output, /App asset verification passed/); }); // 缺少 App 平台编译器时 `uni build -p app` 不会报错,只会静默产出带 /h5/ 基路径的 // H5 空壳(无 app-service.js/app-renderjs.js),使 build:app 成为假绿,renderjs // 实时对练代码实际从未被 App 编译器处理。 test('App 平台编译器已声明且与其他 uni 包同版本,避免 build:app 静默回落 H5', async () => { const pkg = await readJson('../package.json'); const appPlus = pkg.dependencies?.['@dcloudio/uni-app-plus']; assert.ok(appPlus, '缺少 @dcloudio/uni-app-plus,build:app 会静默产出 H5 空壳'); assert.equal(appPlus, pkg.dependencies['@dcloudio/uni-app']); assert.equal(appPlus, pkg.devDependencies['@dcloudio/vite-plugin-uni']); });