Content-Length: 234164 | pFad | http://github.com/tapjs/tapjs/issues/1036

E5 [BUG] t.same does not print diffs for missing props · Issue #1036 · tapjs/tapjs · GitHub
Skip to content

[BUG] t.same does not print diffs for missing props #1036

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

Open
3 tasks done
Hornwitser opened this issue Jul 29, 2024 · 0 comments
Open
3 tasks done

[BUG] t.same does not print diffs for missing props #1036

Hornwitser opened this issue Jul 29, 2024 · 0 comments
Labels
bug something not go good

Comments

@Hornwitser
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Have you read the CONTRIBUTING guide on posting bugs, and CODE_OF_CONDUCT?

  • yes I read the things

This issue exists in the latest tap version

  • I am using the latest tap

Description

When comparing objects with t.same you get a very helpful diff showing what did not match the expected object.

image

However, when the difference exists only between a prop with the value undefined and a prop that is missing, the check fails but it does not show any difference between the compared objects:

image

A deft developer may know that Node.js's built-in assert module has no such issues, and try using it to see if tap is broken. Unfortunately, if this is done inside of an async test in tap then tap will hijack the assert's output, and replace it with it's own broken output that does not show the undefined entries.

image

This leads to a really bad DX that drives one into the weeds trying to figure out what's wrong.

Reproduction

Run t.same against an object with a property with the value undefined and an object with the same property missing.

import t from "tap"
t.same({}, { a: undefined })

The same issue also occurs with strictSame, match, matchOnly, matchOnlyStrict, matchStrict, equal, has, and probably a few more.

// All of these print the assertion failed with no diff
t.same({ a: null }, { })
t.strictSame({ a: undefined }, { })
t.match({ }, { a: undefined });
t.match({ }, { a: null });
t.matchOnly({ a: undefined }, { })
t.matchOnly({ a: null }, { })
t.matchStrict({ }, { a: undefined });
t.matchOnlyStrict({ }, { a: undefined });
t.equal({ a: undefined }, { })
t.has({ }, { a: undefined })
t.has({ }, { a: null })
t.hasStrict({ }, { a: undefined });

Environment

$ pnpm ls tap
dependencies:
tap 21.0.0
$ pnpm tap versions
tap: 21.0.0
"@tapjs/config": 5.0.0
"@tapjs/core": 4.0.0
"@tapjs/run": 4.0.0
"@tapjs/stack": 4.0.0
"@tapjs/test": 4.0.0
tap-parser: 18.0.0
tap-yaml: 4.0.0
tcompare: 9.0.0
plugins:
  "@tapjs/after": 3.0.0
  "@tapjs/after-each": 4.0.0
  "@tapjs/asserts": 4.0.0
  "@tapjs/before": 4.0.0
  "@tapjs/before-each": 4.0.0
  "@tapjs/chdir": 3.0.0
  "@tapjs/filter": 4.0.0
  "@tapjs/fixture": 4.0.0
  "@tapjs/intercept": 4.0.0
  "@tapjs/mock": 4.0.0
  "@tapjs/node-serialize": 4.0.0
  "@tapjs/snapshot": 4.0.0
  "@tapjs/spawn": 4.0.0
  "@tapjs/stdin": 4.0.0
  "@tapjs/typescript": 3.0.0
  "@tapjs/worker": 4.0.0
$ tap config list
# vim: set filetype=yaml :
browser: true
color: true
coverage-report:
  - text
exclude:
  - "**/@(fixture*(s)|dist)/**"
include:
  - "**/@(test?(s)|__test?(s)__)/**/*.@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
  - "**/*.@(test?(s)|spec).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
  - "**/test?(s).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
jobs: 6
reporter: base
snapshot-clean-cwd: true
timeout: 30
$ tap plugin list
@tapjs/after
@tapjs/after-each
@tapjs/asserts
@tapjs/before
@tapjs/before-each
@tapjs/chdir
@tapjs/filter
@tapjs/fixture
@tapjs/intercept
@tapjs/mock
@tapjs/node-serialize
@tapjs/snapshot
@tapjs/spawn
@tapjs/stdin
@tapjs/typescript
@tapjs/worker
$ uname -a
Linux localhost 6.8.4-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 05 Apr 2024 00:14:23 +0000 x86_64 GNU/Linux
@Hornwitser Hornwitser added the bug something not go good label Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something not go good
Projects
None yet
Development

No branches or pull requests

1 participant








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tapjs/tapjs/issues/1036

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy