GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — wd/examples/promise/mocha-specs.js at master · admc/wd

Expand file tree

/

mocha-specs.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
115 lines (98 loc) · 2.86 KB
/

mocha-specs.js

Copy path

File metadata and controls

115 lines (98 loc) · 2.86 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* global describe, it, before , beforeEach, after*/
require('colors');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
chai.should();
var wd;
try {
wd = require('wd');
} catch( err ) {
wd = require('../../lib/main');
}
// enables chai assertion chaining
chaiAsPromised.transferPromiseness = wd.transferPromiseness;
describe('mocha spec examples', function() {
this.timeout(10000);
// returning promises and chai-as-promised is the best way
describe("using promises and chai-as-promised", function() {
var browser;
before(function() {
browser = wd.promiseChainRemote();
// optional extra logging
browser.on('status', function(info) {
console.log(info.cyan);
});
browser.on('command', function(eventType, command, response) {
console.log(' > ' + eventType.cyan, command, (response || '').grey);
});
browser.on('http', function(meth, path, data) {
console.log(' > ' + meth.magenta, path, (data || '').grey);
});
return browser
.init({browserName:'chrome'});
});
beforeEach(function() {
return browser.get("http://admc.io/wd/test-pages/guinea-pig.html");
});
after(function() {
return browser
.quit();
});
it("should retrieve the page title", function() {
return browser
.title().should.become("WD Tests");
});
it("submit element should be clicked", function() {
return browser
.elementById("submit")
.click()
.eval("window.location.href").should.eventually.include("&submit");
});
});
// regular mocha usage is also an option
describe("regular mocha usage", function() {
var browser;
before(function(done) {
browser = wd.promiseChainRemote();
//browser._debugPromise();
browser.on('status', function(info) {
console.log(info);
});
browser.on('command', function(meth, path, data) {
console.log(' > ' + meth, path, data || '');
});
browser
.init({browserName:'chrome'})
.nodeify(done); //same as : .then(function() { done(); });
});
beforeEach(function(done) {
browser
.get("http://admc.io/wd/test-pages/guinea-pig.html")
.nodeify(done);
});
after(function(done) {
browser
.quit()
.nodeify(done);
});
it("should retrieve the page title", function(done) {
browser
.title()
.then(function(title) {
title.should.equal("WD Tests");
})
.nodeify(done);
});
it("submit element should be clicked", function(done) {
browser
.elementById("submit")
.click()
.eval("window.location.href")
.then(function(location) {
location.should.include("&submit");
})
.nodeify(done);
});
});
});
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.