teddyzeenny / ember-mocha-adapter

A mocha adapter for ember-testing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`mocha.checkLeaks()`: noop or bad?

eoinkelly opened this issue · comments

In issue #8 you said "I don't let mocha track global leaks; not sure if it's possible since Ember testing helpers are injected globally by default." Does this mean that calling mocha.checkLeaks() is a noop or is actively bad? In either case I would like to add it to this project's README if you will accept it.

It is reasonable that you don't want README to have to track API in other projects but this is a non-obvious change in what a mocha user would expect so I think it is worth highlighting.

cheers
/Eoin/

mocha.checkLeaks() is not a noop. I'm not very familiar with it, so I don't really know if it will work or not (though the fact about global helpers seems like it would be bad).

This isn't really related to the adapter, more to ember-testing itself (since the global helpers are injected by ember-testing not this adapter).

I have mixed feelings about whether it should be in the README. Did it cause you any trouble?

It doesn't seem to do anything at all (in so far as I can tell):

      mocha.checkLeaks();
      // everything works even if the following is commented out
      mocha.globals([
        // Ember globals:
        'Ember', 'DS', 'App',
        // Ember.Test registered helpers:
        'visit', 'click', 'keyEvent', 'fillIn',
        'find', 'findWithAssert', 'wait', 'andThen'
      ]);

FWIW I think it should be in the README as it seems misleading to have people assume that it works when it does not. Let me know what you decide and I'll PR if required.

I don't see a reason why this adapter would break checkLeaks. We can't add it to the README if we don't really know what is causing it.

Do you see any reason why checkLeaks is broken? Possibly unrelated to ember testing or the adapter? When does it stop working specifically, when you include the adapter?

I will try to investigate further when I find some time. If you have time to figure out what's really happening then perfect :)

I played with this a bit - it seems checkLeaks works fine but my understanding of it was broken. mocha.checkLeaks() compares the collection of globals that exist before & after each test and will trigger an error if they are different. It does not care about how you manage the globals before the tests run.

The upside is that Ember's helpers are not affected by this so it's not a problem :-)