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
Testing code with promises #30
Comments
So I have good news and bad news. Same test, just different testing framework: const Leakage = require('leakage');
var assert = require('assert');
describe('leaks', function() {
let expected, actual;
beforeEach(function() {
expected = 0;
actual = 0;
});
afterEach(function() {
if (!expected || expected == actual) return;
var err = new Error('expected ' + expected + ' assertions, got ' + actual);
this.currentTest.emit('error', err);
});
it('leak test', function() {
this.timeout(100000);
expected = 181;
return Leakage.iterate.async(async () => {
let dummyPromise = new Promise((resolve) => {
setTimeout(() => resolve('ok'), 1);
});
try {
const result = await dummyPromise;
assert.equal(result, 'ok');
actual++;
} catch (e) {
throw 'this should not happen ' + e;
}
});
})
}); With mocha it passes and it's also much faster - 5s. With Jest it fails but it's also much slower
I was unable to pass the |
Thanks for the comprehensive update! 👍🙂 I suppose we can turn that into one actionable only: Document that you should use tape or mocha; test runners that come with a minimal overhead and don‘t do much magic. |
Hey,
I'm trying to test code that uses promises and always getting the
MemoryLeakError
.Is there anything I'm doing wrong, or is that just how promises work?
here's my code:
and very minimalistic
package.json
The text was updated successfully, but these errors were encountered: