Skip to content

Commit 4aa8ea9

Browse files
committed
feat: initialize project
1 parent 6b1d6c4 commit 4aa8ea9

File tree

6 files changed

+4849
-0
lines changed

6 files changed

+4849
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# miniprogram-auto-validator
2+
3+
## Intro
4+
5+
通过编写测试代码验证微信小程序功能
6+
7+
基于 [miniprogram-automator](https://www.npmjs.com/package/miniprogram-automator) + [jest](https://github.com/facebook/jest)
8+
9+
> `miniprogram-automator` 用于操作 [微信开发者工具](https://developers.weixin.qq.com/miniprogram/dev/devtools/devtools.html)
10+
> `jest` 编写相关测试代码
11+
12+
## Start
13+
14+
TODO
15+
16+
## Others
17+
18+
- [`miniprogram-automator` 使用说明](https://developers.weixin.qq.com/miniprogram/dev/devtools/auto/)

examples/miniprogram-demo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit f9ef86212e1447b546e28210cdbfc789c491098a

index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const automator = require('miniprogram-automator')
2+
3+
automator.launch({
4+
cliPath: 'D:\\Software\\wechat_devtools\\Installation\\微信web开发者工具\\cli.bat', // 工具 cli 位置,如果你没有更改过默认安装位置,可以忽略此项
5+
projectPath: './examples/miniprogram-demo', // 项目文件地址
6+
}).then(async miniProgram => {
7+
const page = await miniProgram.reLaunch('/page/component/index')
8+
await page.waitFor(500)
9+
const element = await page.$('.kind-list-item-hd')
10+
console.log(await element.attribute('class'))
11+
await element.tap()
12+
13+
await miniProgram.close()
14+
})

index.spec.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const automator = require('miniprogram-automator')
2+
3+
describe('index', () => {
4+
let miniProgram
5+
let page
6+
7+
beforeAll(async () => {
8+
miniProgram = await automator.launch({
9+
cliPath: 'D:\\Software\\wechat_devtools\\Installation\\微信web开发者工具\\cli.bat',
10+
projectPath: './examples/miniprogram-demo'
11+
})
12+
page = await miniProgram.reLaunch('/page/component/index')
13+
await page.waitFor(500)
14+
}, 300000)
15+
16+
afterAll(async () => {
17+
await miniProgram.close()
18+
})
19+
it('desc', async () => {
20+
const desc = await page.$('.index-desc')
21+
expect(desc.tagName).toBe('view')
22+
expect(await desc.text()).toContain('以下将展示小程序官方组件能力')
23+
})
24+
it('list', async () => {
25+
const lists = await page.$$('.kind-list-item')
26+
expect(lists.length).toBe(9)
27+
const list = await lists[0].$('.kind-list-item-hd')
28+
expect(await list.text()).toBe('视图容器')
29+
})
30+
it('list action', async () => {
31+
const listHead = await page.$('.kind-list-item-hd')
32+
expect(await listHead.attribute('class')).toBe('kind-list-item-hd')
33+
await listHead.tap()
34+
await page.waitFor(200)
35+
expect(await listHead.attribute('class')).toBe(
36+
'kind-list-item-hd kind-list-item-hd-show',
37+
)
38+
await listHead.tap()
39+
await page.waitFor(200)
40+
expect(await listHead.attribute('class')).toBe('kind-list-item-hd')
41+
await listHead.tap()
42+
await page.waitFor(200)
43+
const item = await page.$('.index-bd navigator')
44+
await item.tap()
45+
await page.waitFor(500)
46+
expect((await miniProgram.currentPage()).path).toBe('page/component/pages/view/view')
47+
})
48+
})

0 commit comments

Comments
 (0)