The library for web and native user interfaces.
After each test, remove any stray nodes added to the document.
This was not necessary when we were running each test in its own `<iframe>`, and it doesn't seem to affect any test behavior currently, but it seems wise for the sake of test isolation and hygiene.
Ben Newman committed
Jul 19, 2013 at 13:53 UTC
36fbd8d9412c599608888e18b104c820ffaefea4
2 files changed
+19
-1
src/test/all.js
+9
@@ -43,3 +43,12 @@ require("./mock-timers");
43
exports.enableTest = function(testID) {
44
require("../" + testID);
45
};
46
+
47
+exports.removeSiblings = function(node) {
48
+ var parent = node && node.parentNode;
49
+ if (parent) {
50
+ while (node.nextSibling) {
51
+ parent.removeChild(node.nextSibling);
52
+ }
53
+ }
54
+};
test/index.html
+10
-1
@@ -8,7 +8,16 @@
8
<body>
9
<script>
10
ENABLE_TESTS_HERE
11
- jasmine.getEnv().execute();
11
+
12
+ (function(env) {
13
+ // Clean up any nodes the previous test might have added.
14
+ env.afterEach(function() {
15
+ harness.removeSiblings(document.body);
16
+ harness.removeSiblings(document.getElementById("HTMLReporter"));
17
+ });
18
+
19
+ env.execute();
20
+ })(jasmine.getEnv());
21
</script>
22
</body>
23
</html>