-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
RFC: Drop "ember-mocha-adapter" in favor of a wrapper function #115
Comments
I use How is this better than async/await, which should work fine today (provided the necessary polyfills)?
|
@dwickern it is not better than async/await, but async/await isn't that widely available and simply not the default recommendation yet. In fact your example could probably even be simplified to this: it('acceptance test works', async function() {
await visit('/');
expect(currentURL()).to.equal('/foobar');
}); in other words:
that is precisely what I am proposing :) |
This seems good to me, however it will require another round of blueprint updates based on version (which will be annoying) 😝 |
@rwjblue I know, but this will only require an update to the |
maybe we should use the name |
see #116 (comment) |
We are currently using
ember-mocha-adapter
to implement async acceptance tests using the built-in async Ember helpers, without usingdone()
or returning aPromise
. Theember-mocha-adapter
is implementing this by overriding theit()
function and patching in our custom async handling. This is however error-prone and brittle as demonstrated by e.g. ember-cli/ember-cli-mocha#73 which shows that this approach will no longer work with Mocha 3.x.A potential solution to this is using a wrapper function like this:
The
emberAsync()
function will call the passed in function and return aPromise
waiting for any async behavior that was triggered inside the passed in function, e.g. byreturn wait()
orreturn andThen(function() {})
ifwait()
is not yet available in Ember.My initial spike used the function name
async()
instead ofemberAsync()
, but @rwjblue correctly pointed out that this will lead to naming conflicts with the upcoming async/await feature and we should try to avoid that. I'd be happy to hear other naming suggestions though.see also teddyzeenny/ember-mocha-adapter#35 (comment)
/cc @rwjblue @trentmwillis @teddyzeenny @dgeb
The text was updated successfully, but these errors were encountered: