discourse/test
Martin Brennan 0e09c5837f DEV: Try once more to make acceptance test fake timers work
In my original PR (#9647) I attempted to solve the problem of
using fake timers in acceptance tests by using the new sinon
clock.tickAsync methods. This way of doing things seems to be flawed,
however, as we are getting random spec timeouts starting with the
bookmark acceptance test where this was introduced.

I think I was going about things the wrong way. This commit introduces
a new function with callback (acceptanceUseFakeClock) that sets up the
fake timers using sinon.useFakeTimers with the shouldAdvanceTime option
set to true. This advances time at a normal rate of 20ms per tick, which
means that we are not freezing any time and existing setTimeout funcs.
should proceed as normal. Along with this the callback passed will
run clock.reset() at the end to make sure all the timers are cleaned
up correctly.

There is an optional third parameter after the callback, which is the
timezone. If the user is logged in for the acceptance test then their
timezone is used, otherwise we default to America/Denver.

Usage is (inside an acceptance test):

```
test("Name of the test", async assert => {
  // first parameter is time to start fake clock at
  await acceptanceUseFakeClock("2020-05-04T13:00:00", async () => {
    // test code goes here e.g. await visit("/url");
  });
});
```
2020-05-13 15:16:07 +10:00
..
javascripts DEV: Try once more to make acceptance test fake timers work 2020-05-13 15:16:07 +10:00
stylesheets Manage qunit via yarn. 2018-09-11 15:07:28 +08:00
run-qunit.js DEV: use REPORT_REQUESTS=1 to find all requests 2020-04-02 16:01:49 +11:00
smoke_test.js DEV: Use classes for styling user and group cards (#8913) 2020-02-13 09:58:17 +00:00