Skip to content

Commit

Permalink
upgrade fake timers and others (#2612)
Browse files Browse the repository at this point in the history
* Upgrade dependencies (includes breaking API in Fake Timers)

* fake-timers: no longer creating dates using the original Date class, but a subclass (proxy)

* Clarify intent and fix breaking test on global restore

This was originally added (really rectified) in commit ac17669 (2013) when Sinon's fake-timers code allowed installing non-standard/unknown timers.

Since the latest fake-timers no longer allows this, we have to do the test against a real/existing timer that the library knows about. We supply a custom global to avoid any of the mentioned side effects of trying to delete built-ins in some environments.

* Clarify intent and fix breaking test concerning non-inherited timer

* fix test: fake-timers now installs all timers by default (including nextTick)

* Various micro-fixes in the tests

* Exclude Node timers and timers/promises modules from bundle
  • Loading branch information
fatso83 authored Sep 11, 2024
1 parent c9fd3a9 commit 912c568
Show file tree
Hide file tree
Showing 4 changed files with 574 additions and 440 deletions.
21 changes: 12 additions & 9 deletions build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ try {
* @param done
*/
function makeBundle(entryPoint, config, done) {
browserify(entryPoint, config).bundle(function (err, buffer) {
if (err) {
throw err;
}
done(buffer.toString());
});
browserify(entryPoint, config)
.exclude("timers")
.exclude("timers/promises")
.bundle(function (err, buffer) {
if (err) {
throw err;
}
done(buffer.toString());
});
}

makeBundle(
Expand All @@ -45,7 +48,7 @@ makeBundle(
function (bundle) {
var script = preamble + bundle;
fs.writeFileSync("pkg/sinon.js", script); // WebWorker can only load js files
}
},
);

makeBundle(
Expand All @@ -59,7 +62,7 @@ makeBundle(
function (bundle) {
var script = preamble + bundle;
fs.writeFileSync("pkg/sinon-no-sourcemaps.cjs", script);
}
},
);

makeBundle(
Expand All @@ -78,5 +81,5 @@ makeBundle(

var script = preamble + intro + bundle + outro;
fs.writeFileSync("pkg/sinon-esm.js", script);
}
},
);
Loading

0 comments on commit 912c568

Please sign in to comment.