Skip to content
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

Updated README.md and added mocha to run the existing test. #1

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ As soon as you keep a reference to an object, array, arrow function, ... you do

```js
import myLib from 'my-lib'
import { iterate } from 'leakage'
import { iteration } from 'leakage'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! It took me a moment to figure out why my import wasn't working before I discovered the name was different.


describe('myLib', () => {
it('does not leak when doing stuff 1k times', () => {
iterate(1000, () => {
iteration(1000, () => {
const instance = myLib.createInstance()
instance.doStuff('foo', 'bar')
})
})
})
```

`iterate()` will run the arrow function 1000 times and throw an error if a memory leak has been detected.
`iteration()` will run the arrow function 1000 times and throw an error if a memory leak has been detected.

**Make sure you run all tests serially** in order to get clean heap diffs. Mocha should run them sequentially by default. Use `--runInBand` for Jest.

Expand All @@ -44,17 +44,17 @@ describe('myLib', () => {
```js
import test from 'ava'
import myLib from 'my-lib'
import { iterate } from 'leakage'
import { iteration } from 'leakage'

test('myLib does not leak when doing stuff 1k times', () => {
iterate(1000, () => {
iteration(1000, () => {
const instance = myLib.createInstance()
instance.doStuff('foo', 'bar')
})
})
```

`iterate()` will run the arrow function 1000 times and throw an error if a memory leak has been detected.
`iteration()` will run the arrow function 1000 times and throw an error if a memory leak has been detected.

**Make sure you run all tests serially** in order to get clean heap diffs. Tape should run them sequentially by default. Use `--serial` for AVA.

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Memory leak testing for node. Write tests using your favorite test runner.",
"main": "lib/index.js",
"scripts": {
"test": "standard lib/**/*.js"
"test": "node_modules/.bin/standard lib/**/*.js && node_modules/.bin/mocha test"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm adds node_modules/.bin to PATH, so you can use standard and mocha without the manual path prefix

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't know they added this. Thank you.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Sure thing! Here's that section in the docs, in case you're interested in reading more: https://docs.npmjs.com/misc/scripts#path

},
"author": "Andy Wermke <andy@dev.next-step-software.com>",
"license": "MIT",
Expand All @@ -15,6 +15,7 @@
"pretty-bytes": "^4.0.2"
},
"devDependencies": {
"mocha": "^3.2.0",
"standard": "^8.6.0"
}
}