Files
prop-ai-hr/mobile-uni/tests/app-packaging.test.mjs
T
adminandClaude Opus 5 a3a5cf944e build(mobile): declare App platform compiler to stop build:app false green
`@dcloudio/uni-app-plus` was never declared, so `uni build -p app` silently
fell back to an H5 shell: exit code 0, `DONE Build complete.`, but the output
was only `index.html` (still carrying the `/h5/assets/...` base path) with no
`app-service.js`, `app-renderjs.js` or `manifest.json`. Because
`docs/MOBILE_APP_PACKAGING.md` lists that command as a local verification
step, App platform code was reported as built without ever reaching the App
compiler.

Declare the compiler at the same version as the other `@dcloudio` packages,
guard the version alignment in `tests/app-packaging.test.mjs`, and document
that success is judged by the emitted artifacts, not by the DONE line.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-25 23:56:47 +08:00

30 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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']);
});