Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: switch lolex to new name @sinonjs/fake-timers #15595

Merged
merged 9 commits into from
Apr 19, 2021
6 changes: 3 additions & 3 deletions packages/driver/cypress/integration/commands/clock_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ describe('src/cy/commands/clock', () => {
})
})

it('proxies lolex clock, replacing window time methods', function (done) {
it('proxies @sinonjs/fake-timers clock, replacing window time methods', function (done) {
expect(this.setTimeoutSpy).not.to.be.called

cy.clock().then(function (clock) {
// lolex calls setTimeout once as part of its setup
// @sinonjs/fake-timers calls setTimeout once as part of its setup
// but it shouldn't be called again by the @window.setTimeout()
expect(this.setTimeoutSpy).to.be.calledOnce
this.window.setTimeout(() => {
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('src/cy/commands/clock', () => {
})
})

// this test was written to catch a bug in lolex (dep) 3 and is fixed by lolex 4 upgrade,
// this test was written to catch a bug in lolex (dep, now @sinonjs/fake-timers) 3 and was fixed by lolex 4 upgrade,
it('doesn\'t override window.performance members', () => {
cy.clock()
.then((clock) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@packages/runner": "0.0.0-development",
"@packages/server": "0.0.0-development",
"@packages/ts": "0.0.0-development",
"@sinonjs/fake-timers": "7.0.2",
"@types/chalk": "^2.2.0",
"@types/common-tags": "^1.8.0",
"@types/lodash": "^4.14.168",
Expand Down Expand Up @@ -52,7 +53,6 @@
"js-cookie": "2.2.1",
"jsdom": "14.1.0",
"lodash": "4.17.19",
"lolex": "4.1.0",
"md5": "2.3.0",
"method-override": "3.0.0",
"methods": "1.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const blobUtil = require('blob-util')
const minimatch = require('minimatch')
const Promise = require('bluebird')
const sinon = require('sinon')
const lolex = require('lolex')
const fakeTimers = require('@sinonjs/fake-timers')

const $dom = require('./dom')
const $errorMessages = require('./cypress/error_messages')
Expand Down Expand Up @@ -630,7 +630,7 @@ $Cypress.prototype.Blob = blobUtil
$Cypress.prototype.Promise = Promise
$Cypress.prototype.minimatch = minimatch
$Cypress.prototype.sinon = sinon
$Cypress.prototype.lolex = lolex
$Cypress.prototype.lolex = fakeTimers

// attaching these so they are accessible
// via the runner + integration spec helper
Expand Down
7 changes: 3 additions & 4 deletions packages/driver/src/cypress/clock.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const _ = require('lodash')
const lolex = require('lolex')
const fakeTimers = require('@sinonjs/fake-timers')

const install = (win, now, methods) => {
return lolex.withGlobal(win).install({
target: win,
return fakeTimers.withGlobal(win).install({
now,
toFake: methods,
})
Expand All @@ -23,7 +22,7 @@ const create = (win, now, methods) => {
// reset the hadOwnProperty in case a
// the application code eradicated the
// overridden clock method at a later time.
// this is a property that lolex using internally
// this is a property that @sinonjs/fake-timers using internally
// when restoring the global methods.
// https://github.com/cypress-io/cypress/issues/2850
const fn = clock[method]
Expand Down
12 changes: 7 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6532,6 +6532,13 @@
dependencies:
type-detect "4.0.8"

"@sinonjs/fake-timers@7.0.2":
version "7.0.2"
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-7.0.2.tgz#a53e71d4154ee704ea9b36a6d0b0780e246fadd1"
integrity sha512-dF84L5YC90gIOegPDCYymPIsDmwMWWSh7BwfDXQYePi8lVIEp7IZ1UVGkME8FjXOsDPxan12x4aaK+Lo6wVh9A==
dependencies:
"@sinonjs/commons" "^1.7.0"

"@sinonjs/fake-timers@^6.0.0", "@sinonjs/fake-timers@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-6.0.1.tgz#293674fccb3262ac782c7aadfdeca86b10c75c40"
Expand Down Expand Up @@ -25987,11 +25994,6 @@ lolex@1.3.2:
resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31"
integrity sha1-fD2mL/yzDw9agKJWbKJORdigHzE=

lolex@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/lolex/-/lolex-4.1.0.tgz#ecdd7b86539391d8237947a3419aa8ac975f0fe1"
integrity sha512-BYxIEXiVq5lGIXeVHnsFzqa1TxN5acnKnPCdlZSpzm8viNEOhiigupA4vTQ9HEFQ6nLTQ9wQOgBknJgzUYQ9Aw==

lolex@^2.4.2:
version "2.7.5"
resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.7.5.tgz#113001d56bfc7e02d56e36291cc5c413d1aa0733"
Expand Down