Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
95b7aa9
feat: add test
Aug 15, 2025
1d1f3b0
save
Aug 19, 2025
b37f3ea
feat: add unit
Aug 19, 2025
675aff4
feat: add unit
Aug 20, 2025
51f251b
chore: 删除coverage
Aug 20, 2025
2de8e22
feat: add unit
Aug 20, 2025
6701575
chore: 单测工具迁移
Aug 20, 2025
3cd9aa9
chore: 新增test:react命令
Aug 20, 2025
15563cf
chore: 删除无用文件
Aug 20, 2025
ac5e357
chore: 删除无用文件
Aug 20, 2025
d065c71
chore: 删除无用文件
Aug 20, 2025
7025e76
chore: 修改 jest 配置
Aug 20, 2025
5268868
chore: 调整单测目录
Aug 20, 2025
c5ead17
chore: 调整单测目录
Aug 20, 2025
2b4f439
chore: 调整单测目录
Aug 20, 2025
9222df0
chore: 升级jest
Aug 21, 2025
dec632e
chore: 补充单测用例
Aug 21, 2025
a8b9b03
chore: 补充单测用例
Aug 21, 2025
f383b03
chore: 补充scroll-view单测用例
Aug 21, 2025
f9e5f7f
chore: 修改三方库mock
Aug 21, 2025
64d9485
chore: 补充单测用例
Aug 22, 2025
5502c28
chore: 补充单测用例
Aug 25, 2025
e5ad408
chore: 补充单测用例
Aug 26, 2025
283cfed
feat: 添加 react 测试
Sep 2, 2025
2167364
feat: 添加 react 测试
Sep 2, 2025
47e4ea2
chore: 降级react版本
Sep 3, 2025
9ba3988
chore: 降级react-test-renderer
Sep 3, 2025
b6bbd9e
chore: 降级react-test-renderer
Sep 3, 2025
6825d37
fix: lint error
Sep 3, 2025
13438c5
chore: 补充scroll-view refresh case
Sep 3, 2025
1cc35d1
Merge branch 'master' into feat-rn-jest-v2
Oct 13, 2025
26e464e
chore: update input case
Oct 13, 2025
fecab8e
chore: 补充单测case
Oct 14, 2025
a21cb3e
Merge branch 'master' into feat-rn-jest-v2
Jul 6, 2026
c46e38c
添加单测
Jul 7, 2026
1a1c25d
feat: 补充单测提交
Jul 10, 2026
22f906b
fix: 完善 RN 组件事件及 Jest 单测
Jul 13, 2026
52d6723
test: 完善 RN 运行时单测覆盖
Jul 14, 2026
8b1ebb6
Merge branch 'master' into feat-rn-jest-v2
Jul 14, 2026
b1f66c4
test: 补充 RN SectionList 运行时单测
Jul 14, 2026
2485291
fix: 修正 RN swiper change 事件来源
Jul 14, 2026
df2eb06
test: 补充 RN runtime 组件分支覆盖
Jul 14, 2026
0f3a326
docs: 回退 RN 组件事件文档
Jul 14, 2026
c058ce3
test: 完善 RN runtime 单测覆盖
Jul 16, 2026
beb0c8f
Merge branch 'master' into feat-rn-jest-v2
Jul 21, 2026
f7bd010
test: 归并 RN 组件运行时用例
Jul 21, 2026
69117f9
docs: update doc
Jul 21, 2026
e80e67a
docs: update doc
Jul 21, 2026
a55f2c2
test: 整理 RN 组件测试场景
Jul 21, 2026
6559e57
test: 拆分并强化 RN 组件测试场景
Jul 21, 2026
96509b2
Merge branch 'master' into feat-rn-jest-v2
Jul 23, 2026
57cdec4
fix: 修复 RN runtime 组件问题
Jul 27, 2026
d4f2c3a
docs: 移除 RN 组件修复文档变更
Jul 27, 2026
c75eccb
fix: 移除 swiper 组件改动
Jul 27, 2026
843b0d5
Merge branch 'fix-rn-runtime-components' into feat-rn-jest-v2
Jul 27, 2026
eb1ecec
ci: 按需执行 RN 组件单测
Jul 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: test

on: [push, pull_request]

permissions:
contents: read
pull-requests: read

jobs:
tsc:
runs-on: ubuntu-latest
Expand All @@ -19,6 +23,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: detect RN component changes
id: changes
uses: dorny/paths-filter@v4
with:
filters: |
rn_components:
- 'packages/webpack-plugin/lib/runtime/components/react/**'
- 'packages/webpack-plugin/test/runtime/react-native/components/**'
- 'packages/webpack-plugin/test/__mocks__/**'
- 'packages/webpack-plugin/jest.config.react.json'
- name: Cache node modules
id: cache
uses: actions/cache@v4
Expand Down Expand Up @@ -59,4 +73,8 @@ jobs:
run: npm run build:tsc

- name: exec unit test
run: npm t && npm t --prefix test/e2e/miniprogram-project && npm t --prefix test/e2e/plugin-project
run: npm run test:base && npm t --prefix test/e2e/miniprogram-project && npm t --prefix test/e2e/plugin-project

- name: exec RN component unit test
if: steps.changes.outputs.rn_components == 'true'
run: npm run test:react -w @mpxjs/webpack-plugin
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ docs-vitepress/.vitepress/dist
docs-vitepress/.vitepress/cache
dev-dist
packages/webpack-plugin/lib/runtime/components/react/dist/
coverage/
packages/perf/dist/
.agent-workflows/
.agents/skills/mpx/
3 changes: 1 addition & 2 deletions docs-vitepress/guide/rn/component.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ movable-view的可移动区域。

| 事件名 | 说明 |
| ----------------| ------------------ |
| change | radio-group 中选中项发生改变时触发 change 事件,`detail = { value: [ 选中的 radio 的 value 的数组 ] }` |

| change | radio-group 中选中项发生改变时触发 change 事件,`detail = { value: [ 选中的 radio 的 value 的数组 ] }` |

### form
表单。
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"lint": "eslint --ext .js,.ts,.tsx,.jsx packages/",
"fix": "eslint --fix --ext .js,.ts,.tsx,.jsx packages/",
"lint:js": "eslint --ext .js packages/",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
"test": "npm run test:base && npm run test:react -w @mpxjs/webpack-plugin",
"test:base": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
"test:review-loop": "jest --config .agents/skills/review-loop/jest.config.json --runInBand",
"release": "npm run lint && npm run test && npx lerna version",
"lerna:publish": "lerna publish from-package --yes",
Expand Down
14 changes: 11 additions & 3 deletions packages/webpack-plugin/jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
},
"testEnvironment": "jsdom",
"moduleNameMapper": {
"\\.(css|styl)$": "identity-obj-proxy"
"\\.(css|styl)$": "identity-obj-proxy",
"^@mpxjs/utils$": "<rootDir>/../utils/src/index.js"
},
"setupFiles": ["<rootDir>/test/runtime/react-native/setup.js"],
"testTimeout": 10000
"testPathIgnorePatterns": [
"/node_modules/",
"/dist/",
"test/runtime/react-native/components/"
],
"transformIgnorePatterns": [
"node_modules/(?!(\\.pnpm/)?(react-native|@react-native|react-native-.*|@react-navigation|@mpxjs))"
],
"setupFiles": ["<rootDir>/test/runtime/react-native/setup.js"]
}
47 changes: 47 additions & 0 deletions packages/webpack-plugin/jest.config.react.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": ["babel-jest", { "rootMode": "upward" }]
},
"testEnvironment": "node",
"coverageProvider": "v8",
"moduleNameMapper": {
"\\.(css|styl)$": "identity-obj-proxy",
"^@mpxjs/utils$": "<rootDir>/../utils/src/index.js",
"^react-native$": "<rootDir>/test/__mocks__/react-native-pure.js",
"^react-native-safe-area-context$": "<rootDir>/test/__mocks__/react-native-safe-area-context.js",
"^react-native-linear-gradient$": "<rootDir>/test/__mocks__/react-native-linear-gradient.js",
"^react-native-gesture-handler$": "<rootDir>/test/__mocks__/react-native-gesture-handler.js",
"^react-native-reanimated$": "<rootDir>/test/__mocks__/react-native-reanimated.js",
"^react-native-fast-image$": "<rootDir>/test/__mocks__/react-native-fast-image.js",
"^@d11/react-native-fast-image$": "<rootDir>/test/__mocks__/react-native-fast-image.js",
"\\.(png|jpg|jpeg|gif|webp)$": "<rootDir>/test/__mocks__/fileMock.js"
},
"setupFilesAfterEnv": [
"<rootDir>/test/runtime/react-native/components/setup.js"
],
"testMatch": [
"<rootDir>/test/runtime/react-native/components/**/*.test.(js|jsx|ts|tsx)"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/dist/"
],
"collectCoverageFrom": [
"lib/runtime/components/react/**/*.{ts,tsx}",
"!lib/runtime/components/react/**/*.d.ts",
"!lib/runtime/components/react/dist/**",
"!lib/runtime/components/react/mpx-canvas/html.ts",
"!lib/runtime/components/react/mpx-picker/type.ts"
],
"coverageThreshold": {
"global": {
"statements": 90,
"functions": 90,
"lines": 90,
"branches": 90
}
},
"transformIgnorePatterns": [
"node_modules/(?!(\\.pnpm/)?(react-native|@react-native|react-native-.*|@react-navigation|@mpxjs))"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface CameraProps {
flash?: 'auto' | 'on' | 'off'
'frame-size'?: 'small' | 'medium' | 'large'
style?: Record<string, any>
bindstop?: () => void
bindstop?: (event: Record<string, any>) => void
binderror?: (error: { message: string }) => void
bindinitdone?: (result: { type: string, data: string }) => void
bindscancode?: (result: { type: string, data: string }) => void
Expand Down Expand Up @@ -177,7 +177,7 @@ const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: Ca
}, [bindinitdone, maxZoom])

const onStopped = useCallback(() => {
bindstop && bindstop()
bindstop && bindstop(getCustomEvent('stop', {}, { layoutRef }))
}, [bindstop])

const camera: CameraRef = useMemo(() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export class Image {
canvas: any;
width: number;
height: number;
private _loadListener: any;
private _errorListener: any;
private _removeLoadListener?: () => void;
private _removeErrorListener?: () => void;
private _onload: ((...args: any[]) => void);
private _onerror: ((...args: any[]) => void);
[key: string]: any;
Expand Down Expand Up @@ -70,12 +70,8 @@ export class Image {

set onload (callback: ((...args: any[]) => void)) {
this._onload = callback
if (this._loadListener) {
this.canvas.removeMessageListener(this._loadListener)
}
if (callback) {
this._loadListener = this.addEventListener('load', callback)
}
this._removeLoadListener?.()
this._removeLoadListener = callback ? this.addEventListener('load', callback) : undefined
}

get onload (): ((...args: any[]) => void) {
Expand All @@ -84,12 +80,8 @@ export class Image {

set onerror (callback: ((...args: any[]) => void)) {
this._onerror = callback
if (this._errorListener) {
this.canvas.removeMessageListener(this._errorListener)
}
if (callback) {
this._errorListener = this.addEventListener('error', callback)
}
this._removeErrorListener?.()
this._removeErrorListener = callback ? this.addEventListener('error', callback) : undefined
}

get onerror () : ((...args: any[]) => void) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
}

const removeMessageListener = (listener: any) => {
canvasRef.current.listeners.splice(canvasRef.current.listeners.indexOf(listener), 1)
const index = canvasRef.current.listeners.indexOf(listener)
if (index > -1) {
canvasRef.current.listeners.splice(index, 1)
}
}

const onMessage = useCallback((e: { nativeEvent: { data: string } }) => {
Expand Down Expand Up @@ -288,22 +291,22 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
allowUniversalAccessFromFileURLs: true
})
)
} else {
canvasComponent = createElement(View, innerProps, createElement(WebView, {
ref: (element: WebViewInstance | null) => {
if (canvasRef.current) {
canvasRef.current.webview = element
}
},
style: [stylesheet.webview, { height, width }],
source: { html },
originWhitelist: originWhitelist,
onMessage: onMessage,
onLoad: onLoad,
scrollEnabled: false
}))
}

canvasComponent = createElement(View, innerProps, createElement(WebView, {
ref: (element: WebViewInstance | null) => {
if (canvasRef.current) {
canvasRef.current.webview = element
}
},
style: [stylesheet.webview, { height, width }],
source: { html },
originWhitelist: originWhitelist,
onMessage: onMessage,
onLoad: onLoad,
scrollEnabled: false
}))

if (hasPositionFixed) {
canvasComponent = createElement(Portal, null, canvasComponent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const CheckboxGroup = forwardRef<
bindchange &&
bindchange(
getCustomEvent(
'tap',
'change',
evt,
{
layoutRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface FormProps {
value: any
}
}) => void
bindreset?: () => void
bindreset?: (evt: Record<string, any>) => void
}

const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: FormProps, ref): JSX.Element => {
Expand Down Expand Up @@ -98,7 +98,7 @@ const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: For

const reset = () => {
const { bindreset } = propsRef.current
bindreset && bindreset()
bindreset && bindreset(getCustomEvent('reset', {}, { layoutRef }, propsRef.current))
formValuesMap.forEach(item => item.resetValue())
}
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const valueChanged2Obj = (currentObj: FormatObj, value: number[], limit = 3) =>
const rangeArr = currentObj.rangeArr

if (limit === 3 && (currentValue[0] !== value[0] || currentValue[1] !== value[1])) {
const days = daysInMonth(value[0], value[1] + 1)
const days = daysInMonth(value[0] + START_YEAR, value[1] + 1)
rangeArr[2] = days
const maxIndex = days.length - 1
if (value[2] > maxIndex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ const Picker = forwardRef<HandlerRef<View, PickerProps>, PickerProps>(
}

const onCancel = () => {
bindcancel?.()
bindcancel?.(getCustomEvent('cancel', {}, { layoutRef }, props))
hide()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const radioGroup = forwardRef<
bindchange &&
bindchange(
getCustomEvent(
'tap',
'change',
evt,
{
layoutRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
const headerTopRef = useRef(0)

useEffect(() => {
registerStickyHeader({ key: id, updatePosition })
registerStickyHeader({ id, updatePosition })
return () => {
unregisterStickyHeader(id)
}
Expand Down
Loading
Loading