Skip to content

Commit

Permalink
chore: replace moment with dayjs in driver code
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmodise committed Nov 6, 2020
1 parent 1c2a175 commit e8a6341
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"compression": "1.7.4",
"cors": "2.8.5",
"cypress-multi-reporters": "1.4.0",
"dayjs": "1.9.5",
"debug": "4.1.1",
"error-stack-parser": "2.0.6",
"errorhandler": "1.5.1",
Expand All @@ -58,7 +59,6 @@
"minimatch": "3.0.4",
"minimist": "1.2.5",
"mocha": "7.0.1",
"moment": "2.27.0",
"morgan": "1.9.1",
"ordinal": "1.0.3",
"react-15.6.1": "npm:react@15.6.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const moment = require('moment')
const dayjs = require('dayjs')

moment.updateLocale('en', {
dayjs.updateLocale('en', {
relativeTime: {
future: 'in %s',
past: '%s ago',
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/cy/keyboard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Promise from 'bluebird'
import Debug from 'debug'
import _ from 'lodash'
import moment from 'moment'
import dayjs from 'dayjs'
import $errUtils from '../cypress/error_utils'
import { USKeyboard } from '../cypress/UsKeyboardLayout'
import * as $dom from '../dom'
Expand Down Expand Up @@ -405,7 +405,7 @@ const validateTyping = (
if (
_.isString(chars) &&
dateChars &&
moment(dateChars[0]).isValid()
dayjs(dateChars[0]).isValid()
) {
skipCheckUntilIndex = _getEndIndex(chars, dateChars[0])

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 @@ -2,7 +2,7 @@ const _ = require('lodash')
const $ = require('jquery')
const blobUtil = require('blob-util')
const minimatch = require('minimatch')
const moment = require('moment')
const dayjs = require('dayjs')
const Promise = require('bluebird')
const sinon = require('sinon')
const lolex = require('lolex')
Expand Down Expand Up @@ -628,7 +628,7 @@ $Cypress.prototype.Screenshot = $Screenshot
$Cypress.prototype.SelectorPlayground = $SelectorPlayground
$Cypress.prototype.utils = $utils
$Cypress.prototype._ = _
$Cypress.prototype.moment = moment
$Cypress.prototype.dayjs = dayjs
$Cypress.prototype.Blob = blobUtil
$Cypress.prototype.Promise = Promise
$Cypress.prototype.minimatch = minimatch
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/cypress/runner.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable prefer-rest-params */
/* globals Cypress */
const _ = require('lodash')
const moment = require('moment')
const dayjs = require('dayjs')
const Promise = require('bluebird')
const Pending = require('mocha/lib/pending')

Expand Down Expand Up @@ -1119,7 +1119,7 @@ const create = (specWindow, mocha, Cypress, cy) => {

run (fn) {
if (_startTime == null) {
_startTime = moment().toJSON()
_startTime = dayjs().toJSON()
}

_runnerListeners(_runner, Cypress, _emissions, getTestById, getTest, setTest, getHookId, getTestFromHookOrFindTest)
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/cypress/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const _ = require('lodash')
const capitalize = require('underscore.string/capitalize')
const methods = require('methods')
const moment = require('moment')
const dayjs = require('dayjs')

const $jquery = require('../dom/jquery')
const $Location = require('./location')
Expand Down Expand Up @@ -279,7 +279,7 @@ module.exports = {
},

addTwentyYears () {
return moment().add(20, 'years').unix()
return dayjs().add(20, 'years').unix()
},

locReload (forceReload, win) {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ require('setimmediate')
require('./config/bluebird')
require('./config/jquery')
require('./config/lodash')
require('./config/moment')
require('./config/dayjs')

module.exports = require('./cypress')
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11942,6 +11942,11 @@ daty@^1.0.7:
diff-dates "^1.0.0"
formatoid "^1.0.0"

dayjs@1.9.5:
version "1.9.5"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.9.5.tgz#fd49994ebe71639d2ce9575e97186642dfce9808"
integrity sha512-WULIw7UpW/E0y6VywewpbXAMH3d5cZijEhoHLwM+OMVbk/NtchKS/W+57H/0P1rqU7gHrAArjiRLHCUhgMQl6w==

dayjs@^1.9.3:
version "1.9.3"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.9.3.tgz#b7f94b22ad2a136a4ca02a01ab68ae893fe1a268"
Expand Down

0 comments on commit e8a6341

Please sign in to comment.