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

Inconsistent Mixin testing behavior #226

Closed
adamdonahue opened this issue May 25, 2016 · 6 comments
Closed

Inconsistent Mixin testing behavior #226

adamdonahue opened this issue May 25, 2016 · 6 comments

Comments

@adamdonahue
Copy link

adamdonahue commented May 25, 2016

We're trying to test a Mixin using the pattern generated by ember g mixin. But we're seeing inconsistent behavior.

The test is easy:

  const ObjectWithMixin = Ember.Object.extend(Mixin);
  const objToTest = ObjectWithMixin.create();
  return this.PUBLIC_API.forEach(api=> {
    return ok(objUnderTest.actions[api]);
  });

this.PUBLIC_API is defined in the beforeEach hook of the module call:

module('Unit | Mixin | auto completeable', {
  beforeEach() {
    return this.PUBLIC_API = ['actionX', 'actionY'];
  }
});

Simple. All we're doing here is testing that the actions defined on the mixin are incorporated into the object into which it's being mixed in.

And yet when we run this via IrisUI we see two conflicting behaviors.

Sometimes objToTest in the test has its actions property defined; but other times it is undefined and the test fails referencing an undefined object. It seems to be there's some race condition here in how the objects are created, but it's got us somewhat stumped. Is this a known bug, or is there some other workaround?

@rwjblue
Copy link
Member

rwjblue commented May 25, 2016

Is this in an application or addon? What Ember version is this being tested on?

My only guess is that you are running tests on Ember 1.13 (where obj.actions is undefined) and on some 2.x version (where obj.actions is defined). This is obviously a giant WAG though, to really dig in I'll need a reproduction.

@adamdonahue
Copy link
Author

I intended to list the version. It's 1.13.15. It's an application. Not sure how easy it will be to reproduce our environment, but I'll see if I can some up with a full application that exhibits the same behavior.

@adamdonahue
Copy link
Author

I tried reproducing this in a clean environment but I can't do so. I'm at a loss as to what is happening. I guess we'll have to find a workaround.

@rwjblue
Copy link
Member

rwjblue commented May 25, 2016

Depending on what you mix the thing into it will change the resulting location.

In Ember 1.13, anything that normally has "actions" defined has that prop moved to _actions.

@adamdonahue
Copy link
Author

It literally changes somewhat randomly between test reloads. In any case, adding

const actions = objUnderTest.actions || objUnderTest._actions;

seems to fix the issue.

@rwjblue
Copy link
Member

rwjblue commented May 26, 2016

Ya, if that is the case, there isn't much to be done here. This was a pretty weird thing that was done in Ember 1.x (and deprecated). Moving to Ember 2.0 should remove the inconsistency.

Closing...

@rwjblue rwjblue closed this as completed May 26, 2016
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

No branches or pull requests

2 participants