forked from schickling/chromeless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmocha-chai-test-example.js
44 lines (32 loc) · 1.36 KB
/
mocha-chai-test-example.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
const { Chromeless } = require('chromeless')
const { expect } = require('chai')
// make sure you do npm i chai
// to run this example just run
// mocha path/to/this/file
describe('When searching on google', function () {
it('shows results', async function () {
this.timeout(10000); //we need to increase the timeout or else mocha will exit with an error
const chromeless = new Chromeless()
await chromeless.goto('https://google.com')
.wait('input[name="q"]')
.type('chromeless github', 'input[name="q"]')
.press(13) // press enter
.wait('#resultStats')
const result = await chromeless.exists('a[href*="graphcool/chromeless"]')
expect(result).to.be.true
await chromeless.end()
})
})
describe('When clicking on the image of the demo playground', function () {
it('should redirect to the demo', async function () {
this.timeout(10000); //we need to increase the timeout or else mocha will exit with an error
const chromeless = new Chromeless()
await chromeless.goto('https://github.com/graphcool/chromeless')
.wait('a[href="https://chromeless.netlify.com/"]')
.click('a[href="https://chromeless.netlify.com/"]')
.wait('#root')
const url = await chromeless.evaluate(url => window.location.href)
expect(url).to.match(/^https\:\/\/chromeless\.netlify\.com/)
await chromeless.end()
})
})