Skip to content

Testing Components that use ember-debug-logger #5

Open

Description

@rstudner

I have a component, I happily have this.debug("yay!"); inside of it.

When I run the test for the component I see:

        Died on test #1 http://localhost:7357/assets/tests.js:1175:24
        exports@http://localhost:7357/assets/vendor.js:140:37
        requireModule@http://localhost:7357/assets/vendor.js:32:25
        require@http://localhost:7357/assets/test-support.js:7124:14
        loadModules@http://localhost:7357/assets/test-support.js:7116:21
        load@http://localhost:7357/assets/test-support.js:7146:33
        http://localhost:7357/assets/test-support.js:7030:22: undefined is not a constructor (evaluating 'this.debug("yay!")')
    Log: |
...

any simple recommended way to get around this?

(i've tried the simple this.set('debug', etc); to no avail)

Activity

  1. dfreeman commented on Jan 30, 2017

    @dfreeman
    Member

    Unfortunately the way this addon relies on an instance initializer right now makes this a little tricky to pull off. I think something like this ought to work in a component test, though:

    import { initialize } from 'ember-debug-logger/instance-initializers/debug-logger';
    
    // ...
    
    beforeEach() {
      initialize(Ember.getOwner(this));
    }

    The better approach from this end might be to just reopen the relevant classes in a bare module, so you could just import it for the side effect in your test-helper.js. I'll plan to investigate that when I get a chance, but I'd also happily accept a PR in the meantime :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions