-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--delay does not delay execution of suite functions as expected. #2257
Comments
(EDITTED TO CLARIFY) I believe the delay option only delays actually running the tests. If you want to delay the // process.nextTick to be replaced with your async setup function
process.nextTick(function() {
console.log("in nextTick");
defineTests('bar'); // or "credentials" object w/ user id
run(); // this is exposed when running mocha with the --delay flag
});
function defineTests(foo) {
describe(require('path').basename(__filename), function() {
console.log('describe1 foo: ' + foo);
describe('describe: '+ foo + ' ===? bar', function() {
console.log("describe2 foo: " + foo);
it('it: '+ foo + ' ===? bar', function() {
console.log('within it: ' + foo + ' ===? bar')
require('assert')(true);
});
});
});
} |
Tangentially, from the linked issue it sounds like you may not actually need to delay the describe("asynchronously dynamically generated tests", function() {
doSomethingToGetDataAsynchronously(function(asynchronouslyRetrievedData) {
asynchronouslyRetrievedData.forEach(function(entry) {
it("test for " + entry, function() {
assertStuffAbout(entry);
});
});
run();
});
}); |
Thanks @ScottFreeCode. I will have to take a look at that pattern and see if I can jam it to get what I need done. Unfortunately, the global variable I want to access in Chimp ( Referring to your example above my I wanted to investigate the I think I could achieve what I want if #1628 produced a Any other thoughts are more than welcome! |
Hmm... Yeah, I'm not sure even an option to delay I've looked a little more closely at the linked issue, and one thing's not clear to me -- what is happening between the top-level code running and the I'm not sure I'm reading this right, but it rather looks like this line is when the script containing the |
Chimp wraps all the mocha hooks in fibers in this mocha-fiberized-ui.js I tried pulling the code out of the the idea of a I will take a deeper look when I spring some time loose. Unfortunately for me, once I start gnawing on something I have a hard time stopping. |
Ah, now I see... My inclination is to say that, if the fiberized stuff being set up in the (I also wonder if the fiberization could be done in such a way that any Mocha interface can be chosen... but that's something to dig into some other time, I guess.) Actually, though, is the I totally hear you about having to get to the bottom of things! |
I'm unclear if this is a bug, feature request, or "user error"..? |
If I've understood correctly, it seems to be an issue with Chimp:
Hypothetically, Mocha and Chimp could work together to resolve that by creating a new Mocha hook that runs even before |
Great summary @ScottFreeCode. I have investigated some of
I need to investigate further but it is way back burner right now. So I will close the issue pending more info. |
I am trying to see if I can find a solution to chimp #355.
I tried the demo provided by @boneskull for using
--delay
from #1628.This demo did not demonstrate the expected benefit to using
--delay
. Maybe I am expecting something it does not do?Expected
--delay
flag would delay execution of suite functions or child suite functions untilrun()
is called.Observed
suite functions are executed prior to
run()
call being made.I added some console output and I think that this shows that the
--delay
flag does not allow you to initialize variables prior to any suite functions code being run. You can see from my test console the sequence is:Result:
foo
is only properly set within theit
block.This is exactly the same as not using the
--delay
flag.Modified test @boneskull test
Modified Console output
The text was updated successfully, but these errors were encountered: