question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent Mixin testing behavior

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rwjbluecommented, 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…

0reactions
adamdonahuecommented, May 25, 2016

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

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

seems to fix the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In Python can one implement mixin behavior without using ...
ruby - In Python can one implement mixin behavior without using inheritance? - Stack Overflow. Stack Overflow for Teams – Start collaborating ...
Read more >
digitalmars.D.learn - mixin template scope inconsistency?
Template mixin scope seems to have a weird behavior: I don't understand 'WEIRD(1)' and ... (){ auto a=A(12); } void test1(){ writeln("test.begin"); mixin...
Read more >
Testing Mixins in Isolation with Minitest and RSpec - Semaphore
In this tutorial, we will revisit what mixins are, identify mixin types, and learn how we can test mixins with the most popular...
Read more >
Should @infix and @mixin be soft modifiers? - #8 by arturopala ...
Behavior only, i.e., does not impact elaboration nor type checking, nor even interop, but can affect run-time behavior: @strictfp , @volatile , lazy;...
Read more >
Sass Guidelines
The last remaining inconsistencies are gathered and listed by myself under ... of CSS compatibility and making sure every general behavior is consistent....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found