Skip to content

Commit 684530e

Browse files
author
zhuqingan.3
committed
fix: 构建尝试
1 parent 2815104 commit 684530e

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

packages/taro-components/__mocks__/setup.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,26 @@
22
process.env.TARO_ENV = 'h5'
33
process.env.TARO_PLATFORM = 'web'
44
process.env.SUPPORT_TARO_POLYFILL = 'disabled'
5+
process.env.PUPPETEER_HEADLESS = 'new'
56

67
// @ts-ignore
78
globalThis.MutationObserver = class {
89
constructor (_callback) {}
910
disconnect () {}
1011
observe (_element, _initObject) {}
1112
}
13+
14+
// 统一放大 Puppeteer 启动超时时间,并补充 CI 友好的启动参数
15+
try {
16+
// eslint-disable-next-line @typescript-eslint/no-var-requires
17+
const puppeteer = require('puppeteer')
18+
const originalLaunch = puppeteer.launch
19+
puppeteer.launch = (options = {}) => {
20+
const opt = options as any
21+
const timeout = 90_000
22+
const args = ['--no-sandbox', '--disable-dev-shm-usage', ...(opt.args || [])]
23+
return originalLaunch.call(puppeteer, { timeout, ...opt, args })
24+
}
25+
} catch (e) {
26+
// ignore if puppeteer is unavailable in some environments
27+
}

packages/taro-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"sync:types": "pnpm run tsx --files scripts/json-schema-to-types.ts",
4141
"pretest:ci": "node ./node_modules/puppeteer/install.js",
4242
"test": "cross-env NODE_ENV=test stencil test --spec --e2e",
43-
"test:ci": "pnpm test -- --ci -i --coverage --silent --no-build --max-workers=2",
43+
"test:ci": "pnpm test -- --ci -i --coverage --silent --no-build --runInBand --maxWorkers=1",
4444
"test:coverage": "pnpm test -- --ci --screenshot --coverage",
4545
"test:watch": "pnpm test -- --screenshot --watch",
4646
"tsx": "ts-node --skipIgnore"

packages/taro-components/scripts/stencil/stencil.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ export const config: Config = {
123123
transformIgnorePatterns: ['<rootDir>/node_modules/'],
124124
// 延长测试整体超时并为 CI 场景的 Chromium 启动加参数
125125
// @ts-expect-error Stencil TestingConfig 未暴露 testTimeout,但底层 Jest 会识别
126-
testTimeout: 90000,
126+
testTimeout: 120000,
127127
browserHeadless: true,
128128
browserArgs: ['--no-sandbox', '--disable-dev-shm-usage'],
129+
// 单 worker 降低内存/启动压力(与 test:ci --runInBand 对齐)
130+
maxWorkers: 1,
129131
},
130132
rollupConfig: {
131133
inputOptions: {

0 commit comments

Comments
 (0)