复现步骤:
npx degit dcloudio/uni-preset-vue#vite-ts my-vue3-project
npm install --save cross-env puppeteer adbkit node-simctl jest playwright @playwright/test
随便搞个测试用例 和官方的jest.config.js
npm run test:h5
- 发布:2022-09-27 14:58
- 更新:2024-03-28 10:41
- 阅读:391
产品分类: uniapp/H5
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 10
HBuilderX类型: 正式
HBuilderX版本号: 3.6.4
浏览器平台: Chrome
浏览器版本: 101.0.4951.41
项目创建方式: HBuilderX
操作步骤:
预期结果:
正常跑测试
正常跑测试
实际结果:
page.goto: Protocol error (Page.navigate): Cannot navigate to invalid URL
=========================== logs ===========================
navigating to "http://192.168.31.43:3000/", waiting until "load"
============================================================
at Object.open (node_modules/@dcloudio/uni-h5/lib/uni.automator.js:78:16)
at create (node_modules/@dcloudio/uni-h5/lib/uni.automator.js:143:11)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 3.936 s
Ran all test suites.
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with --detectOpenHandles
to troubleshoot this issue.
page.goto: Protocol error (Page.navigate): Cannot navigate to invalid URL
=========================== logs ===========================
navigating to "http://192.168.31.43:3000/", waiting until "load"
============================================================
at Object.open (node_modules/@dcloudio/uni-h5/lib/uni.automator.js:78:16)
at create (node_modules/@dcloudio/uni-h5/lib/uni.automator.js:143:11)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 3.936 s
Ran all test suites.
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with --detectOpenHandles
to troubleshoot this issue.
bug描述:
npm run test:h5后内部浏览器正常启动打开了网址 puppeteer也开了 但是弹出about:blank 然后报错
试了vue2项目是正常的
顺便还有一个BUG 如果官方本来是建议 // 为了节省测试时间,可以指定一个 H5 的 url 地址,若不指定,每次运行测试,会先 npm run dev:h5
jest.config.js >testEnvironmentOptions >h5 >url 配置好之后 会报无法连接的错误 无论如何都不行 只有取消 vue2的自动化测试才行
麻烦官方能提供一个最简单的DEMO吗 vue3 typescript的自动化测试的一个文件一个用例就好了啊
info :
uni-app v3.6.3
uni-app cli v2.0.1-alpha-36420220922001
Environment Info:
System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-9700F CPU @ 3.00GHz
Binaries:
Node: 16.16.0 - C:\Pro78\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.11.0 - C:\Pro78\nodejs\npm.CMD
Browsers:
Edge: Not Found
npmPackages:
@dcloudio/types: ^3.0.14 => 3.0.15
@dcloudio/uni-app: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-app-plus: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-app-vite: 3.0.0-alpha-3060420220922001
@dcloudio/uni-app-vue: 3.0.0-alpha-3060420220922001
@dcloudio/uni-automator: ^3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-cli-shared: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-cloud: 3.0.0-alpha-3060420220922001
@dcloudio/uni-components: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-h5: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-h5-vite: 3.0.0-alpha-3060420220922001
@dcloudio/uni-h5-vue: 3.0.0-alpha-3060420220922001
@dcloudio/uni-i18n: 3.0.0-alpha-3060420220922001
@dcloudio/uni-mp-alipay: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-mp-baidu: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-mp-compiler: 3.0.0-alpha-3060420220922001
@dcloudio/uni-mp-kuaishou: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-mp-lark: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-mp-qq: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-mp-toutiao: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-mp-vite: 3.0.0-alpha-3060420220922001
@dcloudio/uni-mp-vue: 3.0.0-alpha-3060420220922001
@dcloudio/uni-mp-weixin: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-nvue-styler: 3.0.0-alpha-3060420220922001
@dcloudio/uni-quickapp-webview: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-shared: 3.0.0-alpha-3060420220922001
@dcloudio/uni-stacktracey: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/uni-stat: 3.0.0-alpha-3060420220922001 (2.0.1-alpha-36420220922001)
@dcloudio/uni-uts-vite: 3.0.0-alpha-3060420220922001
@dcloudio/uts: 3.0.0-alpha-3060420220922001
@dcloudio/uts-win32-x64-msvc: 3.0.0-alpha-3060420220922001
@dcloudio/vite-plugin-uni: 3.0.0-alpha-3060420220922001 => 3.0.0-alpha-3060420220922001
@dcloudio/vue-cli-plugin-uni: ^2.0.1-alpha-36420220922001 => 2.0.1-alpha-36420220922001
@dcloudio/webpack-uni-pages-loader: ^2.0.1-alpha-36420220922001 => 2.0.1-alpha-36420220922001
@intlify/vue-devtools: 9.1.9 (9.2.2)
@vitejs/plugin-vue: 2.3.4
@vitejs/plugin-vue-jsx: 1.3.10
@vue/babel-helper-vue-transform-on: 1.0.2
@vue/babel-plugin-jsx: 1.1.1
@vue/compiler-core: 3.2.39
@vue/compiler-dom: 3.2.39
@vue/compiler-sfc: 3.2.39
@vue/compiler-ssr: 3.2.39
@vue/component-compiler-utils: 3.1.0
@vue/devtools-api: 6.4.1 (6.4.1)
@vue/reactivity: 3.2.39
@vue/reactivity-transform: 3.2.39
@vue/runtime-core: 3.2.39
@vue/runtime-dom: 3.2.39
@vue/server-renderer: 3.2.39
@vue/shared: 3.2.39
mpvue-page-factory: 1.0.1
mpvue-template-compiler: 1.0.13
uni-h5-vue: 2.6.10
uni-mp-vue: 2.6.10
vue: ^3.2.39 => 3.2.39
vue-i18n: ^9.1.9 => 9.2.2
vue-loader: 15.8.3
vue-router: 4.1.5 (4.1.5)
vue-style-loader: 4.1.2
vue-template-compiler: 2.6.11
vue3: 1.0.0
vuex: 3.6.2 (3.6.2)
npmGlobalPackages:
@vue/cli: Not Found
3 个回复
778878net (作者)
function sum(a, b) {
return a + b;
};
describe("sum test", () => {
it('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
test('adds 1 + 1 to equal 3', () => {
expect(sum(1, 1)).toBe(3);
});
})
这个可以
带上program就不行了 无法正常连接
renwenwen - 123
你好 解决了吗
JXWang
可以参考一下这个demo https://github.com/wangjinxin613/uniapp-vue3-cli