Comments (3)
So I have good news and bad news.
Good news is that the test is passing with mocha but failing with jest.
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
$ jest --runInBand
FAIL tests/test.js (26.959s)
β leak test
MemoryLeakError: Heap grew on 6 subsequent garbage collections (180 of 180 iterations) by 362 kB.
Iterations between GCs: 30
Final GC details:
[ 30.3 kB] [+ 378x] [- 2x] system / Context
[ 23.4 kB] [+ 378x] [- 1x] Closure
[ 21.9 kB] [+ 103x] [- 4x] Array
[ 3.6 kB] [+ 31x] [- 1x] Timeout
... (9 more)
at testConstantHeapSize (node_modules/leakage/lib/testConstantHeapSize.js:24:12)
at Object.onAllDone (node_modules/leakage/lib/index.js:130:27)
at Immediate.onHeapDiff (node_modules/leakage/lib/index.js:114:16)
I was unable to pass the --heap-file heap-diff.json
param to jest. It worked with mocha, but mocha doesn't have the issue
from leakage.
Hey @karpikpl!
Your code looks fine so far. Haven't ever tested the lib with Jasmine, though.
Can you please post the exact error output and ideally a heap dump (maybe in a GitHub gist or so)?
from leakage.
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.
from leakage.
Related Issues (20)
- Custom Error HOT 2
- What Terminal are you using? HOT 2
- question with mocha test , how can i detect `iterate` was done ? HOT 2
- Document best practices: console.log HOT 9
- Document best practices HOT 6
- How many iterations to do? HOT 3
- To Do: Add to node-memory-leak-tutorial HOT 3
- Rewrite of the lib for reliable async testing ππ HOT 1
- How to catch a probable false alarm HOT 3
- cannot install on node 10 HOT 6
- Vue.js example code HOT 6
- Can not 'passing'? HOT 2
- Extremely low performance on node.js 11 HOT 3
- Failed to install on Windows HOT 5
- Package not working with NodeJS 12 HOT 18
- Cannot install on node 10.15.1 HOT 5
- Varying results for same test HOT 1
- Testing / CI HOT 5
- Promise support HOT 33
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leakage.