Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4830

Debugging tips and tricks

$
0
0

@rondale_sc wrote:

I’ve learned many tips and tricks from the Ember.js Community slack that have been lost to other users over the years. I know firsthand how valuable knowing the right trick here or there is to unblocking your problem. So let’s hear them!

Criteria and Guidelines:

  1. It should be generic, though posting specifics to QUnit or Mocha seem fine.
  2. It should be small and understandable.
  3. It should provide sufficient detail to help others use and implement it.

Even small things can help people, so don’t think you can’t share because it is “too basic” or “everybody knows that,” because someone out there might not and this could help them.

And a little bit of attribution goes a long way. If you found this out from someone in the Slack channel, give them a shout out.

You’re experience is valuable, so please feel free to share! :smile:

I think it fair that I start.


Get Settled State

Ember’s test harness wants to wait for async behavior to be completed before it advances the test. It does so by returning a wait promise from many of the test helpers (e.g. visit). The wait function is covered very well in this blogpost. To simplify the wait helper returns a promise that resolves when the following things have completed:

  • router transition
  • scheduled run loops
  • waiters
  • jQuery.ajax

And there is a neat way to kinda “cheat” to figure that out.

Take for instance you have a visit('/some-route'), which does return a wait promise, and you debugger; immediately afterward. You can call the following to get easy access to the state of the wait:

require('@ember/test-helpers').getSettledState()

Which will output something that looks like this:

Pretty excellent. You can use that information to narrow down where you should look if, for instance, your test was timing out.

Shout out to @TBieniek for showing me this in the #-testing channel this afternoon. And inspiring me to create this thread.

Happy (bug) hunting!

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4830

Trending Articles