Git Product home page Git Product logo

Comments (9)

jasonmit avatar jasonmit commented on September 22, 2024

Ember.run.cancel to cancel anything outstanding on the run loop queue. It's something you want to get into the habit with testing.

from ember-moment.

Iftahh avatar Iftahh commented on September 22, 2024

@jasonmit Perhaps I misunderstood you, or you misunderstood me...
the testing code looks like this:

test: function() {
   visit("/pending-users");
   andThen(function() {
      assert(...page contains what is expected...);
   }
}

Where would I place the cancel? The only place that makes sense is between the visit to the andThen.
What timer should I pass to the cancel? it accepts a parameter, but there is no way to know the runlater timer set by ember-moment.
Attempting to use instead the (private) method Ember.run.cancelTimers() failed even more tests... I did not debug exactly why.

from ember-moment.

jasonmit avatar jasonmit commented on September 22, 2024

@Iftahh sorry, I do think I misunderstood. Is your project public so I can step through this?

@stefanpenner have anything better in mind than replacing the Ember.run.later with setTimeout + Ember.run?

https://github.com/stefanpenner/ember-moment/blob/master/addon/helpers/moment-from-now.js#L12

from ember-moment.

stefanpenner avatar stefanpenner commented on September 22, 2024

@jasonmit seems like the timer should be canceled in destroy() of that helper

from ember-moment.

jasonmit avatar jasonmit commented on September 22, 2024

👍 will fix shortly

from ember-moment.

stefanpenner avatar stefanpenner commented on September 22, 2024

that wont help the above issue, as the timerwaiters in the test helpers are not granular enough.

The solution in ember will land shortly have async/await is supported in jshint, which will revamp the test helpers. Long story, upside @teddyzeenny and myself spike it was ember conf, it was wonderful and glorious but was blocked on tooling (just jshint) support, and stage 2 TC39 support.

In the interim: you should work-around this, by doing both: #80 (comment)

and the suggested raw setTimeout + Ember.run trick, which wont insert a test waiter, like run.later will.

from ember-moment.

Iftahh avatar Iftahh commented on September 22, 2024

Thank you @jasonmit and @stefanpenner for your quick responses and fix !

@jasonmit my code isn't open source but you should be able to reproduce it very easily -
use ember cli to generate acceptance-test and visit a page containing moment-from-now helper somewhere in the template - that should be enough.

from ember-moment.

jasonmit avatar jasonmit commented on September 22, 2024

3.5.1 published, take it for a spin and report if this issue persists.

P.S., I only fixed this because of your avatar photo.

from ember-moment.

stefanpenner avatar stefanpenner commented on September 22, 2024

Thanks @jasonmit

from ember-moment.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.