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

Comparing undefined to object with null value throws #94

Closed
saibotsivad opened this issue Feb 8, 2021 · 1 comment
Closed

Comparing undefined to object with null value throws #94

saibotsivad opened this issue Feb 8, 2021 · 1 comment

Comments

@saibotsivad
Copy link
Sponsor

Using uvu 0.5.1 with this test:

import { test } from 'uvu'
import * as assert from 'uvu/assert'

assert.equal(undefined, { foo: null })

Running via node with -r esm yields this output:

$  node -r esm /demo-uvu-error/test.js
✘   (0 / 1)

   FAIL  "reproduce error"
    Cannot convert undefined or null to object

    at hasOwnProperty (<anonymous>)
    at sort (/demo-uvu-error/node_modules/uvu/diff/index.js:163:40)
    at compare (/demo-uvu-error/node_modules/uvu/diff/index.js:199:21)
    at assert (/demo-uvu-error/node_modules/uvu/assert/index.js:30:28)
    at Proxy.equal (/demo-uvu-error/node_modules/uvu/assert/index.js:43:2)
    at Object.handler (/demo-uvu-error/test.js:150:12)
    at Number.runner (/demo-uvu-error/node_modules/uvu/dist/index.js:77:16)
    at exec (/demo-uvu-error/node_modules/uvu/dist/index.js:131:39)
    at /demo-uvu-error/node_modules/esm/esm.js:1:34535



  Total:     1
  Passed:    0
  Skipped:   0
  Duration:  2.06ms

I would, of course, expect the output to be something more like

    Expected values to be deeply equal:  (equal)

        ++{}                  (Expected)
        --{ foo: null }    (Actual)

I haven't had time to dig in to the uvu code to see what's going on.

@talentlessguy
Copy link

Same for null

it works with chai and built-in assert though. So definitely a bug in uvu/assert.

the fix could be probably unstrict checking for null and then converting to {}

@lukeed lukeed closed this as completed in 0acb895 Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants