I did some online searching and didn't find any discussion, so let me know if this is as expected. Happy to do a PR if this should be correct behavior
Calling done() multiple times in one test should be a failure, but it succeeds
it('should fail when done called second time', done => {
done();
done();
});
Test fails with "done" called multiple times or some such message
Above code snippet showcases issue. Looks like following test could be added to e2e failures:
test('done();done()', done => {
done();
done();
});
npx envinfo --preset jestPaste the results here:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i5-5287U CPU @ 2.90GHz
Binaries:
Node: 10.3.0 - /usr/local/bin/node
Yarn: 1.5.1 - /usr/local/bin/yarn
npm: 6.1.0 - /usr/local/bin/npm
I agree this should fail. Wanna send a PR for it? 馃榾
Hey, I'd like to take this up. Don't have enough context as it is though. From what I understand, this will have to be updated in both circus and jasmine(Env.js?). Could you give me a place to start?
Circus: https://github.com/facebook/jest/blob/e2dac2ba04bd0655d7f81a02907375429746c05a/packages/jest-circus/src/utils.js#L180-L196
Jasmine: https://github.com/facebook/jest/blob/e2dac2ba04bd0655d7f81a02907375429746c05a/packages/jest-jasmine2/src/jasmine/Env.js#L549-L561
I'm personally fine fixing this just in Circus, but if both are easy, go for it 馃檪
The code for circus looks like something I can work with. The one for jasmine I don't quite grok. I don't see where the callback is provided. Basically what I plan on doing is to wrap done in a higher order function which increments a variable for done being called more than once. If it's called more than once then we mark the test as a fail.
Hello, me and another student are trying to fix this issue for a course in college. However, it's our first time working with jest so we are not so sure which files to run to reproduce this issue... Can you please replicate it in repl.it?
Hey @jmcsilva98, really happy to hear that!
Here's a repl.it, if you run this then the test passes but the OP requests that we fail it. The message could be something like "Expected done to be called once but it was called multiple times"
Here is a good place to start looking to add the feature. Note that this is the jest-circus runner so you should follow these instructions to run
Finally, here are some instructions on how to setup jest locally as well. These docs aren't our best, so if you have any questions, feel free to reach out to me on twitter or the reactiflux discord and I'd be happy to help!
May I give this a shot?
That would be great, thanks!
Most helpful comment
Hello, me and another student are trying to fix this issue for a course in college. However, it's our first time working with jest so we are not so sure which files to run to reproduce this issue... Can you please replicate it in repl.it?