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

This reproduces a bug in AVA (maybe?). Just run $ npm t and you'll … #6

Merged
merged 1 commit into from
Mar 17, 2016

Conversation

kentcdodds
Copy link
Owner

…get:

(node) warning: possible EventEmitter memory leak detected. 11 test listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at TestCollection.addListener (events.js:239:17)
    at Runner.run (/Users/kdodds/Developer/eslint-find-new-rules/node_modules/ava/lib/runner.js:127:13)
    at process.<anonymous> (/Users/kdodds/Developer/eslint-find-new-rules/node_modules/ava/index.js:90:10)
    at emitOne (events.js:77:13)
    at process.emit (events.js:169:7)
    at process.<anonymous> (/Users/kdodds/Developer/eslint-find-new-rules/node_modules/ava/lib/test-worker.js:124:10)
    at emitTwo (events.js:87:13)
    at process.emit (events.js:172:7)
    at handleMessage (internal/child_process.js:689:10)
    at Pipe.channel.onread (internal/child_process.js:440:11)

…get:

(node) warning: possible EventEmitter memory leak detected. 11 test listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at TestCollection.addListener (events.js:239:17)
    at Runner.run (/Users/kdodds/Developer/eslint-find-new-rules/node_modules/ava/lib/runner.js:127:13)
    at process.<anonymous> (/Users/kdodds/Developer/eslint-find-new-rules/node_modules/ava/index.js:90:10)
    at emitOne (events.js:77:13)
    at process.emit (events.js:169:7)
    at process.<anonymous> (/Users/kdodds/Developer/eslint-find-new-rules/node_modules/ava/lib/test-worker.js:124:10)
    at emitTwo (events.js:87:13)
    at process.emit (events.js:172:7)
    at handleMessage (internal/child_process.js:689:10)
    at Pipe.channel.onread (internal/child_process.js:440:11)
@ta2edchimp
Copy link
Collaborator

According to the hint to use proxyquireto mock fs, replacing the mock-fs setup with the following seems to solve the issue:

npm i -D proxyquire
import proxyquire from 'proxyquire'
import test from 'ava'

const findNewRules = proxyquire('../index', {
  fs: {
    readdirSync: () => ['foo-rule.js', 'bar-rule.js', 'baz-thing.js'],
  },
})

(Of course, findNewRules could also be assigned using test.before.)

Edit: it solved the issue with the original tests.
Edit 2: I altered the example above to work with the tests from this PR. Sorry for adding so much noise.

@kentcdodds kentcdodds merged commit 91a3b9b into master Mar 17, 2016
@jamestalmage
Copy link

Cool - this solves it even easier than I was thinking.

I was actually pointing to the mock.fs(..) method of the mock-fs module. It creates a fs clone without clobbering the native one.

Just an FYI - mount-fs looks like a way smarter way to use mock-fs. Use the mock.fs(..) method to create a clone, and mount it in a specific directory using mount-fs.

@kentcdodds kentcdodds deleted the ava-bug branch March 21, 2016 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants