Skip to content

Commit 935bd29

Browse files
committed
add 'unpolyfill' jasmine test asset
- that override DOM methods to catch browser-dependent (i.e. IE) bugs
1 parent 8521f37 commit 935bd29

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

test/jasmine/assets/unpolyfill.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Un-polyfills - to be included in karma.conf.js to catch
3+
* browser-dependent errors.
4+
*/
5+
6+
'use strict';
7+
8+
(function(arr) {
9+
arr.forEach(function(item) {
10+
Object.defineProperty(item, 'remove', {
11+
configurable: true,
12+
enumerable: true,
13+
writable: true,
14+
value: function remove() {
15+
throw Error([
16+
'test/jasmine/assets/unpolyfill.js error: calling ChildNode.remove()',
17+
'which is not available in IE.'
18+
].join(' '));
19+
}
20+
});
21+
});
22+
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);

test/jasmine/karma.conf.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ var pathToStrictD3 = path.join(__dirname, '..', '..', 'tasks', 'util', 'strict_d
106106
var pathToJQuery = path.join(__dirname, 'assets', 'jquery-1.8.3.min.js');
107107
var pathToIE9mock = path.join(__dirname, 'assets', 'ie9_mock.js');
108108
var pathToCustomMatchers = path.join(__dirname, 'assets', 'custom_matchers.js');
109+
var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
109110

110111
var reporters = (isFullSuite && !argv.tags) ? ['dots', 'spec'] : ['progress'];
111112
if(argv.failFast) reporters.push('fail-fast');
@@ -142,7 +143,7 @@ func.defaultConfig = {
142143
// list of files / patterns to load in the browser
143144
//
144145
// N.B. the rest of this field is filled below
145-
files: [pathToCustomMatchers],
146+
files: [pathToCustomMatchers, pathToUnpolyfill],
146147

147148
// list of files / pattern to exclude
148149
exclude: [],

0 commit comments

Comments
 (0)