Skip to content

Commit 37b39ec

Browse files
committed
Add task for running mocha tests with webdriver for testing proxies
1 parent 6d53461 commit 37b39ec

13 files changed

Lines changed: 248 additions & 111 deletions

Gruntfile.js

Lines changed: 55 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,48 @@ module.exports = function(grunt) {
1313
post: '\n}).call({}, window, document);'
1414
};
1515

16-
// Project configuration.
16+
var browsers = {
17+
chrome: {
18+
browserName: "chrome",
19+
platform: "Windows 7",
20+
version: "39"
21+
},
22+
firefox: {
23+
browserName: "firefox",
24+
version: "15",
25+
platform: "Windows 7"
26+
},
27+
ie9: {
28+
browserName: "internet explorer",
29+
version: "9",
30+
platform: "Windows 7"
31+
},
32+
ie10: {
33+
browserName: "internet explorer",
34+
version: "10",
35+
platform: "Windows 8"
36+
},
37+
ie11: {
38+
browserName: "internet explorer",
39+
version: "11",
40+
platform: "Windows 8.1"
41+
},
42+
safari6: {
43+
browserName: "safari",
44+
version: "6",
45+
platform: "OS X 10.8"
46+
},
47+
safari7:{
48+
browserName: "safari",
49+
platform: "OS X 10.9",
50+
version: "7"
51+
},
52+
chromeOSX:{
53+
browserName: "chrome",
54+
platform: "OS X 10.8",
55+
version: "39"
56+
}
57+
};
1758
grunt.initConfig({
1859

1960
pkg: grunt.file.readJSON('package.json'),
@@ -124,48 +165,8 @@ module.exports = function(grunt) {
124165
mocha_phantomjs: {
125166
all: ['tests/mocha/**/*.html']
126167
},
127-
webdriver: {
128-
chrome: {
129-
browserName: "chrome",
130-
platform: "Windows 7",
131-
version: "34"
132-
},
133-
firefox: {
134-
browserName: "firefox",
135-
version: "15",
136-
platform: "Windows 7"
137-
},
138-
ie9: {
139-
browserName: "internet explorer",
140-
version: "9",
141-
platform: "Windows 7"
142-
},
143-
ie10: {
144-
browserName: "internet explorer",
145-
version: "10",
146-
platform: "Windows 8"
147-
},
148-
ie11: {
149-
browserName: "internet explorer",
150-
version: "11",
151-
platform: "Windows 8.1"
152-
},
153-
safari6: {
154-
browserName: "safari",
155-
version: "6",
156-
platform: "OS X 10.8"
157-
},
158-
safari7:{
159-
browserName: "safari",
160-
platform: "OS X 10.9",
161-
version: "7"
162-
},
163-
chromeOSX:{
164-
browserName: "chrome",
165-
platform: "OS X 10.8",
166-
version: "34"
167-
}
168-
}
168+
mocha_webdriver: browsers,
169+
webdriver: browsers
169170
});
170171

171172
grunt.registerTask('webdriver', 'Browser render tests', function(browser, test) {
@@ -180,6 +181,17 @@ module.exports = function(grunt) {
180181
});
181182
});
182183

184+
grunt.registerTask('mocha_webdriver', 'Browser mocha tests', function(browser, test) {
185+
var selenium = require("./tests/mocha/selenium.js");
186+
var done = this.async();
187+
var browsers = (browser) ? [grunt.config.get(this.name + "." + browser)] : _.values(grunt.config.get(this.name));
188+
selenium.tests(browsers, test).catch(function() {
189+
done(false);
190+
}).finally(function() {
191+
done();
192+
});
193+
});
194+
183195
grunt.loadNpmTasks('grunt-mocha-phantomjs');
184196
grunt.loadNpmTasks('grunt-contrib-watch');
185197
grunt.loadNpmTasks('grunt-contrib-concat');

tests/mocha/background.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
width: 200px;
2727
height: 200px;
2828
background-image: -webkit-linear-gradient(top, #008000, #008000);
29+
background-image: -moz-linear-gradient(to bottom, #008000, #008000);
2930
background-image: linear-gradient(to bottom, #008000, #008000);
3031
}
3132
</style>
@@ -126,6 +127,9 @@
126127
else {
127128
mocha.run();
128129
}
130+
mocha.suite.afterAll(function() {
131+
document.body.setAttribute('data-complete', 'true');
132+
});
129133
</script>
130134
</body>
131135
</html>

tests/mocha/colors.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@
136136
else {
137137
mocha.run();
138138
}
139+
mocha.suite.afterAll(function() {
140+
document.body.setAttribute('data-complete', 'true');
141+
});
139142
</script>
140143
</body>
141144
</html>

tests/mocha/cropping.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@
136136
else {
137137
mocha.run();
138138
}
139+
mocha.suite.afterAll(function() {
140+
document.body.setAttribute('data-complete', 'true');
141+
});
139142
</script>
140143
</body>
141144
</html>

tests/mocha/form-rendering.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@
158158
else {
159159
mocha.run();
160160
}
161+
mocha.suite.afterAll(function() {
162+
document.body.setAttribute('data-complete', 'true');
163+
});
161164
</script>
162165
</body>
163166
</html>

tests/mocha/gradients.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ describe("Gradients", function() {
102102
var value = container.css("backgroundImage");
103103
it(value, function() {
104104
var parsedBackground = parseBackgrounds(value);
105+
if (parsedBackground[0].args[0] === "0% 50%") {
106+
parsedBackground[0].args[0] = 'left';
107+
}
105108
expect(parsedBackground[0].args).to.eql(expected[i].args);
106109
expect(parsedBackground[0].method).to.eql(expected[i].method);
107110
});

tests/mocha/multiple-renders.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<script>
2828
describe("Multiple renders", function() {
2929
it("render correctly", function(done) {
30-
this.timeout(5000);
30+
this.timeout(10000);
3131
var d = 0;
3232
var count = 3;
3333
for (var i = 0; i < count; i++) {
@@ -45,7 +45,7 @@
4545
});
4646

4747
it("render correctly when non sequential", function(done) {
48-
this.timeout(5000);
48+
this.timeout(10000);
4949
var d = 0;
5050
var count = 3;
5151
for (var i = 0; i < count; i++) {
@@ -73,13 +73,18 @@
7373
function validCanvasPixels(canvas) {
7474
var ctx = canvas.getContext("2d");
7575
var data = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
76-
for (var i = 0, len = data.length; i < len; i+=4) {
76+
for (var i = 0, len = 200*199*4; i < len; i+=4) {
7777
if (data[i] !== 0 || data[i+1] !== 128 || data[i+2] !== 0 || data[i+3] !== 255) {
78+
console.log(i, data[i], data[i+1], data[i+2], data[i+3]);
7879
expect().fail("Invalid canvas data");
7980
}
8081
}
8182
}
8283

84+
mocha.suite.afterAll(function() {
85+
document.body.setAttribute('data-complete', 'true');
86+
});
87+
8388
mocha.checkLeaks();
8489
mocha.globals(['jQuery']);
8590
if (window.mochaPhantomJS) {

tests/mocha/options.onclone.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
else {
6767
mocha.run();
6868
}
69+
mocha.suite.afterAll(function() {
70+
document.body.setAttribute('data-complete', 'true');
71+
});
6972
</script>
7073
</body>
7174
</html>

tests/mocha/parsing.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@
191191
else {
192192
mocha.run();
193193
}
194+
mocha.suite.afterAll(function() {
195+
document.body.setAttribute('data-complete', 'true');
196+
});
194197
</script>
195198
</body>
196199
</html>

tests/mocha/scrolling.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
else {
6262
mocha.run();
6363
}
64+
mocha.suite.afterAll(function() {
65+
document.body.setAttribute('data-complete', 'true');
66+
});
6467
</script>
6568
</body>
6669
</html>

0 commit comments

Comments
 (0)