-
Notifications
You must be signed in to change notification settings - Fork 1
/
1301.js
59 lines (47 loc) · 1.31 KB
/
1301.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const Nightmare = require('nightmare')
const assert = require('assert')
describe('google', () => {
let nightmare
beforeEach(async () => {
nightmare = Nightmare({ show: false })
})
afterEach(async () => {
const screenshot = await nightmare.screenshot()
console.log(screenshot)
await nightmare.end()
})
it('should check the title', async function() {
this.timeout('10s')
await nightmare.goto('https://google.com')
// test the title
const title = await nightmare.title()
assert.equal(title, 'Google')
})
})
// const Nightmare = require('nightmare')
// const assert = require('assert')
// // your tests
// function TestGoto(tape) {
// test(tape, async nightmare => {
// await nightmare.goto('https://google.com')
// assert.equal('Google', await nightmare.title())
// })
// }
// // test helper
// async function test(tape, fn) {
// const nightmare = Nightmare({ show: false })
// let err
// // don't let failed assertion kill the node process
// try {
// await fn()
// } catch (e) {
// err = e
// tape.fail(err)
// }
// // take a screenshot either way
// const buf = await nightmare.screenshot()
// await fs.writeFile('screenshot.png', buf)
// await nightmare.end()
// // finally fail or pass
// err ? tape.fail(err) : tape.pass()
// }