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.

import { Promise } from 'rsvp'; causes simple tests to fail

See original GitHub issue

A simple component like this:

export default Component.extend({
  actions: {
    show() {
      this.set('show', true);
    }
  }
}) 
<button onclick={{action 'show'}}>show</button>
{{if show 'showing'}}

…and a basic integration test will pass with the new v3 style tests. However, when import { Promise } from 'rsvp'; is added the test will fail

See this example repo

import { Promise as EmberPromise } from rsvp fixes it

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rwjbluecommented, Dec 17, 2017

I’m going to close this issue, but hopefully the breadcrumbs above help folks that might stumble on the same things.

0reactions
rwjbluecommented, Dec 17, 2017

There are three possible fixes here (all of which should probably be done):

  • Run-wrap the click:
Ember.run(() => {
  this.$('button:contains("Show")').trigger('click');
});
  • Upgrade to ember-cli-babel@6.10.0, which includes https://github.com/babel/ember-cli-babel/pull/197 so that the import { Promise } from 'rsvp'; does not force regenerator-runtime to use Ember.RSVP.Promise.

  • Update to use the newer DOM helpers introduced in emberjs/rfcs#268, and released in ember-cli-qunit@4.2.0 (just today). These helpers are async and properly run-wrapped (they also use native DOM events so are more correct than the simulated jQuery events that are being used in the test ATM). The only caveat is that these helpers do not allow the jQuery style selectors (button:contains('Showing')) that are being used here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RSVP.Promise - 3.5 - Ember API Documentation
Promises that are rejected have a rejection reason and are in the rejected state. A fulfillment value is never a thenable.
Read more >
Using Ember (cli) how do I get an acceptance test to wait for a ...
var promise = Ember. Test. promise(function (resolve, reject) {...}); and not those where the promise is instantiated directly, i.e.
Read more >
Should I still be using RSVP over vanilla promises? : r/emberjs
We import RSVP.Promise as EmberPromise, then have a lint rule disallowing native Promise. Too many flaky tests caused by forgetting to use ...
Read more >
Using promises - JavaScript - MDN Web Docs
A Promise is an object representing the eventual completion or failure of an asynchronous operation. Since most people are consumers of ...
Read more >
Testing Async in Ember.js — Part One | by Chris Masters
So that now the loading and error behaviour is encapsulated in a promise. Integration tests. In the case of an integration test you...
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