|
| 1 | +const automator = require('miniprogram-automator') |
| 2 | + |
| 3 | +const projectPath = '<%= projectPath %>' |
| 4 | +const questionPage = '<%= questionPage %>' |
| 5 | +const studentInfo = '<%= studentInfo %>' |
| 6 | + |
| 7 | +let openMp = true |
| 8 | + |
| 9 | +describe(`${studentInfo}-${questionPage}-${projectPath}`, () => { |
| 10 | + let miniProgram |
| 11 | + |
| 12 | + beforeAll(async () => { |
| 13 | + try { |
| 14 | + miniProgram = await automator.launch({ |
| 15 | + cliPath: 'D:\\Software\\wechat_devtools\\Installation\\微信web开发者工具\\cli.bat', |
| 16 | + projectPath |
| 17 | + }) |
| 18 | + } catch (err) { |
| 19 | + openMp = false |
| 20 | + } |
| 21 | + }, 300000) |
| 22 | + |
| 23 | + afterAll(async () => { |
| 24 | + await miniProgram.close() |
| 25 | + }) |
| 26 | + |
| 27 | + it('bupt 前缀', async () => { |
| 28 | + expect(openMp).toBe(true) // 验证是否能正常导入项目,即是该小程序开发者 |
| 29 | + |
| 30 | + const page = await miniProgram.reLaunch(questionPage) |
| 31 | + await page.waitFor(500) |
| 32 | + |
| 33 | + const input1 = await page.$('#input1') |
| 34 | + await input1.input('bupttest') |
| 35 | + await page.waitFor(500) |
| 36 | + const result = await page.$('#result') |
| 37 | + |
| 38 | + expect(await result.text()).toBe('success') |
| 39 | + }, 120000) |
| 40 | + |
| 41 | + it('非 bupt 前缀', async () => { |
| 42 | + expect(openMp).toBe(true) // 验证是否能正常导入项目,即是该小程序开发者 |
| 43 | + |
| 44 | + const page = await miniProgram.reLaunch(questionPage) |
| 45 | + await page.waitFor(500) |
| 46 | + |
| 47 | + const input1 = await page.$('#input1') |
| 48 | + await input1.input('testbupt') |
| 49 | + await page.waitFor(500) |
| 50 | + const result = await page.$('#result') |
| 51 | + |
| 52 | + expect(await result.text()).toBe('failure') |
| 53 | + }, 120000) |
| 54 | +}) |
0 commit comments