测试代码
describe('导航栏', () => {
let page
beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/index/index')
await page.waitFor(10000)
console.log(page)
})
it('标题', async () => {
// 检测标题文本内容
expect(await (await page.$('.nav-bar__title-text')).text()).toBe('哈哈哈')
})
})
jest.config.js
module.exports = {
testTimeout: 20000,
reporters: [
'default'
],
watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
moduleFileExtensions: ['js', 'json'],
rootDir: __dirname,
testMatch: ["<rootDir>/src/**/*test.[jt]s?(x)"],
testPathIgnorePatterns: ['/node_modules/'],
globalTeardown: '@dcloudio/uni-automator/dist/teardown.js',
testEnvironment: '@dcloudio/uni-automator/dist/environment.js',
}
执行命令
npm run test:mp-weixin
得到结果:Failed to launch Wechat web devTools , please make sure http port is open
2***@qq.com (作者)
这些已经全部打开了,依然显示Failed to launch Wechat web devTools , please make sure http port is open
2024-02-26 13:42