Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sinonjs/fake-timers
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v14.0.0
Choose a base ref
...
head repository: sinonjs/fake-timers
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v15.0.0
Choose a head ref
  • 5 commits
  • 11 files changed
  • 3 contributors

Commits on Feb 13, 2025

  1. Bump esbuild from 0.23.1 to 0.25.0 (#523)

    Bumps [esbuild](https://github.com/evanw/esbuild) from 0.23.1 to 0.25.0.
    - [Release notes](https://github.com/evanw/esbuild/releases)
    - [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG-2024.md)
    - [Commits](evanw/esbuild@v0.23.1...v0.25.0)
    
    ---
    updated-dependencies:
    - dependency-name: esbuild
      dependency-type: direct:development
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 13, 2025
    Configuration menu
    Copy the full SHA
    1145a35 View commit details
    Browse the repository at this point in the history

Commits on Sep 18, 2025

  1. feat: Add additional auto advance time controls (#509)

    * feat: Add clock.setTickMode to configure auto advancing time after clock is created
    
    This adds a `setTickMode` method to the Clock to allow developers to
    configure whether time should auto advance and what the delta should be
    after the clock has been created. Prior to this commit, it could only be
    done at creation time with `shouldAdvanceTime: true`.
    
    * feat: Add additional auto advance time controls
    
    TL;DR This adds a new mode for automatically advancing time that moves
    more quickly than the existing shouldAdvanceTime, which uses real time.
    
    Testing with mock clocks can often turn into a real struggle when dealing with situations where some work in the test is truly async and other work is captured by the mock clock.
    
    In addition, when using mock clocks, testers are always forced to write tests with intimate knowledge of when the mock clock needs to be ticked. Oftentimes, the purpose of using a mock clock is to speed up the execution time of the test when there are timeouts involved. It is not often a goal to test the exact timeout values. This can cause tests to be riddled with manual advancements of fake time. It ideal for test code to be written in a way that is independent of whether a mock clock is installed or which mock clock library is used. For example:
    
    ```
    document.getElementById('submit');
    // https://testing-library.com/docs/dom-testing-library/api-async/#waitfor
    await waitFor(() => expect(mockAPI).toHaveBeenCalledTimes(1))
    ```
    
    When mock clocks are involved, the above may not be possible if there is some delay involved between the click and the request to the API. Instead, developers would need to manually tick the clock beyond the delay to trigger the API call.
    
    This is different from the existing `shouldAdvanceTime` in the following
    ways:
    
    `shouldAdvanceTime` is essentially `setInterval(() => clock.tick(ms), ms)` while this feature is `const loop = () => setTimeout(() => clock.nextAsync().then(() => loop()), 0);`
    
    There are two key differences between these two:
    
    1. `shouldAdvanceTime` uses `clock.tick(ms)` so it synchronously runs all timers inside the "ms" of the clock queue. This doesn't allow the microtask queue to empty between the macrotask timers in the clock whereas something like `tickAsync(ms)` (or a loop around `nextAsync`) would. This could arguably be considered a fixable bug in its implementation
    2. `shouldAdvanceTime` uses real time to advance the same amount of real time in the mock clock. The way I understand it, this feels somewhat like "real time with the opportunity to advance more quickly by manually advancing time". This would be quite different: It advances time as quickly possible and as far as necessary. Without manual ticks, `shouldAdvanceTime` would only be capabale of automatically advancing as far as the timeout of the test and take the whole real time of the test timeout. In contrast, `setTickMode({mode: "nextAsync"})` can theoretically advance infinitely far, limited only by processing speed. Somewhat similar to the [--virtual-time-budget](https://developer.chrome.com/docs/chromium/headless#--virtual-time-budget) feature of headless chrome.
    
    In addition to the "quick mode" of `shouldAdvanceTime`, this also adds
    the ability to modify the initially configured values for
    shouldAdvanceTime and advanceTimeDelta.
    atscott authored Sep 18, 2025
    Configuration menu
    Copy the full SHA
    108efae View commit details
    Browse the repository at this point in the history
  2. Upgrade versions (#526)

    * Upgrade versions
    
    * Audit fix to avoid security issues
    
    * Update code-styles from Prettier update
    
    * Update LTS versions
    fatso83 authored Sep 18, 2025
    Configuration menu
    Copy the full SHA
    21dcb13 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    959d237 View commit details
    Browse the repository at this point in the history
  4. 15.0.0

    fatso83 committed Sep 18, 2025
    Configuration menu
    Copy the full SHA
    6020d9b View commit details
    Browse the repository at this point in the history
Loading