mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-01 04:20:23 -05:00
began exploring dynamic loading of suites
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
<div id="test-wrapper">
|
||||
<div id="iframe-wrapper">
|
||||
<div id="iframe-container">
|
||||
<iframe src="/iframes/foo.html" class="iframe-spec"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mocha"></div>
|
||||
|
||||
@@ -7,6 +7,8 @@ window.onerror = function() {
|
||||
window.Mocha = Object.create(parent.Mocha);
|
||||
window.mocha = Object.create(parent.mocha);
|
||||
|
||||
console.log("child setting mocha")
|
||||
|
||||
// In order to isolate top-level before/beforeEach hooks,
|
||||
// the specs in each iframe are wrapped in an anonymous suite.
|
||||
mocha.suite = Mocha.Suite.create(mocha.suite);
|
||||
|
||||
+93
-3
@@ -1,8 +1,98 @@
|
||||
// need to use window.onload here so all of
|
||||
//our iframes and tests are loaded
|
||||
(function(Mocha){
|
||||
|
||||
iframes = ["foo", "bar"];
|
||||
|
||||
var ecl = function ecl(runner){
|
||||
console.log("runner is", runner)
|
||||
|
||||
// runner.suite.addSuite
|
||||
nextSuite(runner)
|
||||
|
||||
// oldRunSuite = runner.runSuite
|
||||
|
||||
// runner.runSuite = function(suite, fn){
|
||||
// if(suite.root){
|
||||
// return oldRunSuite.apply(this, arguments);
|
||||
// }
|
||||
|
||||
// if(suite._hasRun){
|
||||
// console.warn("suite has run", suite, suite.suites)
|
||||
// return
|
||||
// }
|
||||
|
||||
// suite._hasRun = suite._hasRun || true
|
||||
|
||||
// // call the original runSuite
|
||||
// oldRunSuite.apply(this, arguments);
|
||||
// };
|
||||
|
||||
// runner.on("start", function(){
|
||||
// console.log("runner has started", arguments, this)
|
||||
// });
|
||||
|
||||
// runner.on("end", function(){
|
||||
// console.log("runner has ended", arguments, this)
|
||||
// });
|
||||
|
||||
// runner.on("suite", function(suite){
|
||||
// if (suite.root) return;
|
||||
// console.log("suite", suite);
|
||||
// });
|
||||
|
||||
runner.on("suite end", function(suite){
|
||||
if (suite.root) return;
|
||||
// suite._hasRun = true
|
||||
console.log("suite end", suite);
|
||||
// iframe = iframes.shift()
|
||||
// runner.runSuite
|
||||
nextSuite(runner);
|
||||
});
|
||||
|
||||
runner.on("test end", function(test){
|
||||
console.log("test end", test)
|
||||
});
|
||||
}
|
||||
|
||||
var nextSuite = function nextSuite(runner){
|
||||
next = iframes.shift();
|
||||
// $LAB.script("/specs/" + next + "_spec.js").wait(function(){
|
||||
// console.log("loaded", next);
|
||||
// runner.run()
|
||||
// });
|
||||
console.log("next is", next);
|
||||
if(next){
|
||||
iframe = $("<iframe />", {
|
||||
src: "/iframes/" + next + ".html",
|
||||
load: function(){
|
||||
console.info("loaded!", iframe, this);
|
||||
// debugger
|
||||
|
||||
// runner.run()
|
||||
// run each of the iframes suite independently
|
||||
runner.runSuite(this.contentWindow.mocha.suite, function(){
|
||||
console.log("runSuite finished", arguments, this)
|
||||
});
|
||||
}
|
||||
});
|
||||
iframe.appendTo($("#iframe-container"))
|
||||
}
|
||||
};
|
||||
|
||||
mocha = new Mocha({reporter: ecl})
|
||||
|
||||
// var addIframe = function addIframe(){
|
||||
// iframe = iframes.shift()
|
||||
|
||||
// if(iframe){
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
})(Mocha);
|
||||
|
||||
window.onload = function () {
|
||||
|
||||
console.log("running!");
|
||||
console.log("onload!");
|
||||
mocha.run();
|
||||
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
describe("Bar2 Spec", function(){
|
||||
console.warn("bar2 spec")
|
||||
it("can bar2", function(){
|
||||
console.warn("can bar");
|
||||
expect("bar2").to.eq("bar2");
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
describe("Foo Spec", function(){
|
||||
console.warn("foo spec")
|
||||
it("can foo", function(){
|
||||
console.warn("can foo");
|
||||
expect("foo").to.eq("foo");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user