sinonjs / fake-timers

Fake setTimeout and friends (collectively known as "timers"). Useful in your JavaScript tests. Extracted from Sinon.JS
BSD 3-Clause "New" or "Revised" License
794 stars 103 forks source link

New mochify #395

Closed mantoni closed 6 months ago

mantoni commented 2 years ago

Purpose (TL;DR) - mandatory

I'm working on a rewrite of mochify which aims to solve #380, is more modular and works with any bundler.

Background (Problem in detail) - optional

The current mochify implementation is dated and does not support the latest webdriver protocols.

Solution - optional

The new mochify implementation works with pluggable drivers. The @mochify/driver-webdriver uses the official webdriver module internally.

Interestingly, this successfully runs tests in Safari (although there are failing tests), but I'm having trouble running tests in Firefox and Edge.

New Mochify development happens on the rewrite branch here: https://github.com/mantoni/mochify.js/tree/rewrite

codecov[bot] commented 2 years ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (0f28610) 96.49% compared to head (52bd3df) 97.50%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #395 +/- ## ========================================== + Coverage 96.49% 97.50% +1.00% ========================================== Files 2 16 +14 Lines 684 3960 +3276 ========================================== + Hits 660 3861 +3201 - Misses 24 99 +75 ``` | [Flag](https://app.codecov.io/gh/sinonjs/fake-timers/pull/395/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs) | Coverage Δ | | |---|---|---| | [unit](https://app.codecov.io/gh/sinonjs/fake-timers/pull/395/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs) | `97.50% <100.00%> (+1.00%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

fatso83 commented 2 years ago

Only thing that is failing is the missing Chromium:

Run export SINON_CHROME_BIN=$(which google-chrome-stable)

> @sinonjs/fake-timers@7.1.2 test-headless
> mochify --driver puppeteer "--chrome" "/usr/bin/google-chrome-stable" "--allow-chrome-as-root"

Error: Could not find expected browser (chrome) locally. Run `npm install` to download the correct Chromium revision (901912).
mantoni commented 2 years ago

Builds now pass, except for Safari which has failing unit tests.

fatso83 commented 2 years ago

Any idea what the "kl" in the output is? Some debugging statement left in?

> @sinonjs/fake-timers@8.0.0 test-headless /Users/carlerik/dev/fake-timers
> mochify --driver puppeteer

kl

  .................................,,,,,,,,,,,,,,,.........................................................................................................
  .............................................,...,...........,...........................,,...................................,..............,......,,,,,
  ,,,,,,...,,,,,,,,,,,,,,,,,..........,..,,........,,..

  304 passing (5s)
  55 pending
mantoni commented 2 years ago

Any idea what the "kl" in the output is?

When I run it locally with the current state of mochify linked locally, this doesn't appear.

fatso83 commented 2 years ago

Hah, probably me that has fiddled around with node_modules when debugging at some earlier stage and forgot 😄

fatso83 commented 2 years ago

Just wondering about the tests that fail in Safari ... how do I run these Mochify tests locally against a local Safari instance?

mantoni commented 2 years ago

You can launch safaridriver locally. It ships with Safari.

Setup and config examples are documented here: https://github.com/mantoni/mochify.js/blob/rewrite/driver-webdriver/README.md

mantoni commented 6 months ago

I finally manager to get a new Mochify release out and updated this PR.

I have no idea why the selenium job is skipped. Anyone?

Happy Christmas 🎄

mantoni commented 6 months ago

After a small adjustment, tests now also pass in all browsers, including Safari. Unfortunately Safari does not include the function name in the err.stack, so I had to make some assertions less specific.

While testing I also removed Browserify and used ESBuild instead. If this is not wanted, I'm happy to switch it back.