Skip to content

Commit 258191f

Browse files
authored
chore(deps): replace deprecated lodash.isequal (#1911)
* chore(deps): replace deprecated lodash.isequal * chore: replace isDeepStrictEqual with deep-eql * test: add basic tests for compareObject
1 parent 3841052 commit 258191f

File tree

4 files changed

+33
-28
lines changed

4 files changed

+33
-28
lines changed

package-lock.json

Lines changed: 5 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,13 @@
6161
},
6262
"dependencies": {
6363
"@vitest/snapshot": "^3.2.4",
64+
"deep-eql": "^5.0.2",
6465
"expect": "^30.0.0",
65-
"jest-matcher-utils": "^30.0.0",
66-
"lodash.isequal": "^4.5.0"
66+
"jest-matcher-utils": "^30.0.0"
6767
},
6868
"devDependencies": {
6969
"@types/debug": "^4.1.12",
7070
"@types/jest": "^30.0.0",
71-
"@types/lodash.isequal": "^4.5.8",
7271
"@types/node": "^24.0.3",
7372
"@vitest/coverage-v8": "^3.2.4",
7473
"@wdio/eslint": "^0.1.1",

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import isEqual from 'lodash.isequal'
1+
import deepEql from 'deep-eql'
22
import type { ParsedCSSValue } from 'webdriverio'
33

44
import { expect } from 'expect'
@@ -305,7 +305,7 @@ export const compareObject = (actual: object | number, expected: string | number
305305

306306
return {
307307
value: actual,
308-
result: isEqual(actual, expected),
308+
result: deepEql(actual, expected),
309309
}
310310
}
311311

test/utils.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, test, expect } from 'vitest'
2-
import { compareNumbers, compareText, compareTextWithArray } from '../src/utils.js'
2+
import { compareNumbers, compareObject, compareText, compareTextWithArray } from '../src/utils.js'
33

44
describe('utils', () => {
55
describe('compareText', () => {
@@ -135,4 +135,27 @@ describe('utils', () => {
135135
expect(compareNumbers(actual, { lte, gte })).toBe(false)
136136
})
137137
})
138+
139+
describe('compareObject', () => {
140+
test('should pass if the objects are equal', () => {
141+
expect(compareObject({ 'foo': 'bar' }, { 'foo': 'bar' }).result).toBe(true)
142+
})
143+
144+
test('should pass if the objects are deep equal', () => {
145+
expect(compareObject({ 'foo': { 'bar': 'baz' } }, { 'foo': { 'bar': 'baz' } }).result).toBe(true)
146+
})
147+
148+
test('should fail if the objects are not equal', () => {
149+
expect(compareObject({ 'foo': 'bar' }, { 'baz': 'quux' }).result).toBe(false)
150+
})
151+
152+
test('should fail if the objects are only shallow equal', () => {
153+
expect(compareObject({ 'foo': { 'bar': 'baz' } }, { 'foo': { 'baz': 'quux' } }).result).toBe(false)
154+
})
155+
156+
test('should fail if the actual value is a number or array', () => {
157+
expect(compareObject(10, { 'foo': 'bar' }).result).toBe(false)
158+
expect(compareObject([{ 'foo': 'bar' }], { 'foo': 'bar' }).result).toBe(false)
159+
})
160+
})
138161
})

0 commit comments

Comments
 (0)