mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user