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.
This commit is contained in:
Ben Newman
2013-07-19 13:53:15 -04:00
parent a7dfe04406
commit 36fbd8d941
2 changed files with 19 additions and 1 deletions

View File

@@ -43,3 +43,12 @@ require("./mock-timers");
exports.enableTest = function(testID) {
require("../" + testID);
};
exports.removeSiblings = function(node) {
var parent = node && node.parentNode;
if (parent) {
while (node.nextSibling) {
parent.removeChild(node.nextSibling);
}
}
};

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.removeSiblings(document.body);
harness.removeSiblings(document.getElementById("HTMLReporter"));
});
env.execute();
})(jasmine.getEnv());
</script>
</body>
</html>