Abandon <iframe> test isolation hack now that we have dumpCache.

This cuts the running time of `grunt phantom:run` from 4.4s to 3.1s on my
machine, because we no longer have to load/execute a separate instance of
`react-test.js` in a separate `<iframe>` for each test.
This commit is contained in:
Ben Newman
2013-07-19 10:40:43 -04:00
parent 7ef5172d80
commit 5beb481145
5 changed files with 16 additions and 45 deletions

View File

@@ -11,7 +11,7 @@ var jasmine = {
var test = {
rootDirectory: "build/modules",
args: ["test/all:"],
args: ["test/all:harness"],
requires: [
"**/__tests__/*-test.js"
],

View File

@@ -6,9 +6,6 @@ var Ap = Array.prototype;
var slice = Ap.slice;
var Fp = Function.prototype;
var global = Function("return this")();
global.require = require;
if (!Fp.bind) {
// PhantomJS doesn't support Function.prototype.bind natively, so
// polyfill it whenever this module is required.
@@ -58,3 +55,7 @@ require("reactComponentExpect");
require("mocks");
require("mock-modules");
require("./mock-timers");
exports.enableTest = function(testID) {
require("../" + testID);
};

View File

@@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script>
jasmine = parent.jasmine;
jasmine.exposeFrom(window);
console = parent.console;
callPhantom = parent.callPhantom;
</script>
<script src="react-test.js"></script>
</head>
<body>
<script>
require(window.frameElement.getAttribute("test"));
</script>
</body>
</html>

View File

@@ -2,21 +2,13 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="jasmine.css" />
<style type="text/css">
iframe {
visibility: hidden;
position: absolute;
left: -1000px;
top: -1000px;
}
</style>
<script src="jasmine.js"></script>
<script>
window.onload = function() {
jasmine.getEnv().execute();
};
</script>
<script src="react-test.js"></script>
</head>
<body>
<script>
ENABLE_TESTS_HERE
jasmine.getEnv().execute();
</script>
</body>
</html>

View File

@@ -34,14 +34,13 @@ while (argv.length > 0) {
rest.push(arg);
}
// Dynamically interpolate the individual test <iframe>s.
// Dynamically enable the individual tests.
var indexHtml = fs.read("index.html").replace(
/<body>([\s\S]*?)<\/body>/im,
function(outer, inner) {
return "<body>" + tests.map(function(test) {
return '\n <iframe src="frame.html" test=' +
JSON.stringify(test) + '></iframe>';
}).join("") + inner + "</body>";
/^(\s*)ENABLE_TESTS_HERE/m,
function(placeholder, leadingSpace) {
return leadingSpace + tests.map(function(testID) {
return "harness.enableTest(" + JSON.stringify(testID) + ");";
}).join("\n" + leadingSpace);
}
);
@@ -63,9 +62,6 @@ server.listen(port, function(req, res) {
file = "../build/" + file;
break;
case "frame.html":
break;
case "":
default:
file = "index.html";