Merge pull request #213 from benjamn/remove-stray-nodes-after-each-test

After each test, remove any stray nodes added to the document
This commit is contained in:
Paul O’Shannessy
2013-07-19 11:26:50 -07:00
2 changed files with 19 additions and 1 deletions
+9
View File
@@ -43,3 +43,12 @@ require("./mock-timers");
exports.enableTest = function(testID) {
require("../" + testID);
};
exports.removeNextSiblings = function(node) {
var parent = node && node.parentNode;
if (parent) {
while (node.nextSibling) {
parent.removeChild(node.nextSibling);
}
}
};
+10 -1
View File
@@ -8,7 +8,16 @@
<body>
<script>
ENABLE_TESTS_HERE
jasmine.getEnv().execute();
(function(env) {
// Clean up any nodes the previous test might have added.
env.afterEach(function() {
harness.removeNextSiblings(document.body);
harness.removeNextSiblings(document.getElementById("HTMLReporter"));
});
env.execute();
})(jasmine.getEnv());
</script>
</body>
</html>