Skip to content

Commit a8f2eb5

Browse files
committed
Add integration tests to Gruntfile / CI
1 parent acb7790 commit a8f2eb5

File tree

4 files changed

+72
-30
lines changed

4 files changed

+72
-30
lines changed

Gruntfile.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,22 @@ module.exports = function(grunt) {
159159
},
160160

161161
mocha: {
162-
all: {
163-
options: {
164-
mocha: {
165-
ignoreLeaks: true,
166-
grep: grunt.option('grep')
167-
},
168-
log: true,
169-
reporter: 'Dot',
170-
run: true
162+
options: {
163+
mocha: {
164+
ignoreLeaks: true,
165+
grep: grunt.option('grep')
171166
},
167+
log: true,
168+
reporter: 'Dot',
169+
run: true
170+
},
171+
unit: {
172172
src: ['test/index.html'],
173173
nonull: true
174+
},
175+
integration: {
176+
src: ['test/integration/index.html'],
177+
nonull: true
174178
}
175179
},
176180

test/integration/frame.html

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,49 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<title>JS Bin</title>
6-
<script src="../../dist/raven.js"></script>
5+
<title></title>
76
<script>
7+
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
8+
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
9+
10+
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
11+
12+
// MIT license
13+
14+
(function() {
15+
var lastTime = 0;
16+
var vendors = ['ms', 'moz', 'webkit', 'o'];
17+
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
18+
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
19+
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
20+
|| window[vendors[x]+'CancelRequestAnimationFrame'];
21+
}
22+
23+
if (!window.requestAnimationFrame)
24+
window.requestAnimationFrame = function(callback, element) {
25+
var currTime = new Date().getTime();
26+
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
27+
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
28+
timeToCall);
29+
lastTime = currTime + timeToCall;
30+
return id;
31+
};
32+
33+
if (!window.cancelAnimationFrame)
34+
window.cancelAnimationFrame = function(id) {
35+
clearTimeout(id);
36+
};
37+
}());
38+
</script>
39+
<script src="../../build/raven.js"></script>
40+
<script>
41+
// stub _makeRequest so we don't actually transmit any data
842
Raven._makeRequest = function () {};
943

44+
// get a reference to the original, unwrapped setTimeout (used for
45+
// making "clean" stack traces that don't originate from mocha)
1046
window.origSetTimeout = setTimeout;
47+
1148
Raven.config('https://[email protected]/1', {
1249
dataCallback: function (data) {
1350
window.ravenData = data;

test/integration/index.html

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,28 @@
3939
<script src="test.js"></script>
4040

4141
<script>
42-
(function(runner){
43-
window.runner = runner;
44-
var failed = [];
42+
if (!window.PHANTOMJS) {
43+
(function (runner) {
44+
window.runner = runner;
45+
var failed = [];
4546

46-
runner.on('fail', function(test, err){
47-
failed.push({
48-
title: test.title,
49-
fullTitle: test.fullTitle(),
50-
error: {
51-
message: err.message,
52-
stack: err.stack
53-
}
54-
});
55-
});
47+
runner.on('fail', function (test, err) {
48+
failed.push({
49+
title: test.title,
50+
fullTitle: test.fullTitle(),
51+
error: {
52+
message: err.message,
53+
stack: err.stack
54+
}
55+
});
56+
});
5657

57-
runner.on('end', function(){
58-
runner.stats.failed = failed;
59-
window.mochaResults = runner.stats;
60-
});
61-
})(mocha.run());
58+
runner.on('end', function () {
59+
runner.stats.failed = failed;
60+
window.mochaResults = runner.stats;
61+
});
62+
})(mocha.run());
63+
}
6264
</script>
6365
</body>
6466
</html>

test/integration/test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ describe('integration', function () {
196196
},
197197
function () {
198198
var ravenData = iframe.contentWindow.ravenData;
199-
console.log(ravenData);
200199
// # of frames alter significantly between chrome/firefox & safari
201200
assert.isAbove(ravenData.exception.values[0].stacktrace.frames.length, 2);
202201
}

0 commit comments

Comments
 (0)