Skip to content

Expected / actual diff is not show if expected undefined #6619

@jimmyn

Description

@jimmyn

Describe the bug

When expecting a value to be undefined but receiving an object, the diff view is not showing, so it is impossible to see what the object contains

image

If compared to some defined value, it does work correctly

image image

Reproduction

Can be reproduced with the following test:

import {expect, test} from "vitest";

test('demo', () => {
  const error = {
    message: 'Some very long error message',
  }
  expect(error).toBeUndefined();
});

Output

Details
[INFO 18:10:42] [v1.2.17] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 18:10:42] [API] Running Vitest v2.1.1 (vitest-demo/vitest.config.ts) with Node.js@v20.15.1: /Users/dmitriy/.nvm/current/bin/node 
[INFO 18:10:42] [API] Vitest v2.1.1 (vitest-demo/vitest.config.ts) process 19446 created
[INFO 18:10:43] [API] Collecting tests: demo.test.ts
[18:10:43] Not starting the runner because tests are being collected
[18:10:43] There is no test run for "demo.test.ts"
[18:10:43] No test run to finish for demo.test.ts
[INFO 18:10:46] Running 1 file(s) with name pattern: ^\s?demo$
[18:10:46] The runner is starting because tests demo.test.ts were started due to a file change
[18:10:46] Enqueuing "demo"
[18:10:46] No task result for "demo", assuming the test just started running
[18:10:46] Marking "demo" as passed
[18:10:46] Ending test run demo.test.ts
[INFO 18:10:50] Running 1 file(s) with name pattern: ^\s?demo$
[18:10:50] The runner is starting because tests demo.test.ts were started due to a file change
[18:10:50] Enqueuing "demo"
[18:10:50] No task result for "demo", assuming the test just started running
[18:10:50] Marking "demo" as passed
[18:10:50] Ending test run demo.test.ts
[INFO 18:10:50] Running 1 file(s) with name pattern: ^\s?demo$
[18:10:50] The runner is starting because tests demo.test.ts were started due to a file change
[18:10:50] Enqueuing "demo"
[18:10:50] No task result for "demo", assuming the test just started running
[18:10:50] Marking "demo" as passed
[18:10:50] Ending test run demo.test.ts
[INFO 18:10:53] Running 1 file(s) with name pattern: ^\s?demo$
[18:10:53] The runner is starting because tests demo.test.ts were started due to a file change
[18:10:53] Enqueuing "demo"
[18:10:54] No task result for "demo", assuming the test just started running
[18:10:54] Marking "demo" as passed
[18:10:54] Ending test run demo.test.ts
[INFO 18:10:56] [API] Vitest process 19446 closed successfully
[INFO 18:10:56] [API] Running Vitest v2.1.1 (vitest-demo/vitest.config.ts) with Node.js@v20.15.1: /Users/dmitriy/.nvm/current/bin/node 
[INFO 18:10:56] [API] Vitest v2.1.1 (vitest-demo/vitest.config.ts) process 19508 created
[INFO 18:10:56] [API] Collecting tests: demo.test.ts
[18:10:56] Not starting the runner because tests are being collected
[18:10:56] There is no test run for "demo.test.ts"
[18:10:56] No test run to finish for demo.test.ts
[INFO 18:10:57] Running 1 file(s) with name pattern: ^\s?demo$
[18:10:57] The runner is starting because tests demo.test.ts were started due to a file change
[18:10:57] Enqueuing "demo"
[18:10:57] No task result for "demo", assuming the test just started running
[18:10:57] No errors found for "demo.test.ts"
[18:10:57] Marking "demo" as failed with 1 errors
[18:10:57] No errors found for "demo.test.ts"
[18:10:57] Ending test run demo.test.ts
[INFO 18:14:39] [API] Vitest process 19508 closed successfully
[INFO 18:14:39] [API] Running Vitest v2.1.1 (vitest-demo/vitest.config.ts) with Node.js@v20.15.1: /Users/dmitriy/.nvm/current/bin/node 
[INFO 18:14:39] [API] Vitest v2.1.1 (vitest-demo/vitest.config.ts) process 19610 created
[INFO 18:14:39] [API] Collecting tests: demo.test.ts
[18:14:39] Not starting the runner because tests are being collected
[18:14:40] There is no test run for "demo.test.ts"
[18:14:40] No test run to finish for demo.test.ts
[INFO 18:14:41] Running 1 file(s) with name pattern: ^\s?demo$
[18:14:41] The runner is starting because tests demo.test.ts were started due to a file change
[18:14:41] Enqueuing "demo"
[18:14:41] No task result for "demo", assuming the test just started running
[18:14:41] No errors found for "demo.test.ts"
[18:14:41] Marking "demo" as failed with 1 errors
[18:14:41] No errors found for "demo.test.ts"
[18:14:41] Ending test run demo.test.ts
[INFO 18:14:42] Running 1 file(s) with name pattern: ^\s?demo$
[18:14:42] The runner is starting because tests demo.test.ts were started due to a file change
[18:14:42] Enqueuing "demo"
[18:14:42] No task result for "demo", assuming the test just started running
[18:14:42] No errors found for "demo.test.ts"
[18:14:42] Marking "demo" as failed with 1 errors
[18:14:42] No errors found for "demo.test.ts"
[18:14:42] Ending test run demo.test.ts
[INFO 18:14:45] Running 1 file(s) with name pattern: ^\s?demo$
[18:14:45] The runner is starting because tests demo.test.ts were started due to a file change
[18:14:45] Enqueuing "demo"
[18:14:45] No task result for "demo", assuming the test just started running
[18:14:45] No errors found for "demo.test.ts"
[18:14:45] Marking "demo" as failed with 1 errors
[18:14:45] No errors found for "demo.test.ts"
[18:14:45] Ending test run demo.test.ts
[INFO 18:14:59] [API] Vitest process 19610 closed successfully
[INFO 18:14:59] [API] Running Vitest v2.1.1 (vitest-demo/vitest.config.ts) with Node.js@v20.15.1: /Users/dmitriy/.nvm/current/bin/node 
[INFO 18:14:59] [API] Vitest v2.1.1 (vitest-demo/vitest.config.ts) process 19652 created
[INFO 18:14:59] [API] Collecting tests: demo.test.ts
[18:14:59] Not starting the runner because tests are being collected
[18:14:59] There is no test run for "demo.test.ts"
[18:14:59] No test run to finish for demo.test.ts
[INFO 18:15:00] Running 1 file(s) with name pattern: ^\s?demo$
[18:15:00] The runner is starting because tests demo.test.ts were started due to a file change
[18:15:00] Enqueuing "demo"
[18:15:00] No task result for "demo", assuming the test just started running
[18:15:00] No errors found for "demo.test.ts"
[18:15:00] Marking "demo" as failed with 1 errors
[18:15:00] No errors found for "demo.test.ts"
[18:15:00] Ending test run demo.test.ts
[INFO 18:15:01] Running 1 file(s) with name pattern: ^\s?demo$
[18:15:01] The runner is starting because tests demo.test.ts were started due to a file change
[18:15:01] Enqueuing "demo"
[18:15:01] No task result for "demo", assuming the test just started running
[18:15:01] No errors found for "demo.test.ts"
[18:15:01] Marking "demo" as failed with 1 errors
[18:15:01] No errors found for "demo.test.ts"
[18:15:01] Ending test run demo.test.ts
[INFO 18:15:02] Running 1 file(s) with name pattern: ^\s?demo$
[18:15:02] The runner is starting because tests demo.test.ts were started due to a file change
[18:15:02] Enqueuing "demo"
[18:15:02] No task result for "demo", assuming the test just started running
[18:15:02] No errors found for "demo.test.ts"
[18:15:02] Marking "demo" as failed with 1 errors
[18:15:02] No errors found for "demo.test.ts"
[18:15:02] Ending test run demo.test.ts
[INFO 18:15:03] Running 1 file(s) with name pattern: ^\s?demo$
[18:15:03] The runner is starting because tests demo.test.ts were started due to a file change
[18:15:03] Enqueuing "demo"
[18:15:03] No task result for "demo", assuming the test just started running
[18:15:03] No errors found for "demo.test.ts"
[18:15:03] Marking "demo" as failed with 1 errors
[18:15:03] No errors found for "demo.test.ts"
[18:15:03] Ending test run demo.test.ts
[INFO 18:15:04] Running 1 file(s) with name pattern: ^\s?demo$
[18:15:04] The runner is starting because tests demo.test.ts were started due to a file change
[18:15:04] Enqueuing "demo"
[18:15:04] No task result for "demo", assuming the test just started running
[18:15:04] No errors found for "demo.test.ts"
[18:15:04] Marking "demo" as failed with 1 errors
[18:15:04] No errors found for "demo.test.ts"
[18:15:04] Ending test run demo.test.ts
[INFO 18:16:13] [API] Vitest process 19652 closed successfully
[INFO 18:16:13] [API] Running Vitest v2.1.1 (vitest-demo/vitest.config.ts) with Node.js@v20.15.1: /Users/dmitriy/.nvm/current/bin/node 
[INFO 18:16:13] [API] Vitest v2.1.1 (vitest-demo/vitest.config.ts) process 19729 created
[INFO 18:16:13] [API] Collecting tests: demo.test.ts
[18:16:13] Not starting the runner because tests are being collected
[18:16:13] There is no test run for "demo.test.ts"
[18:16:13] No test run to finish for demo.test.ts
[INFO 18:16:14] Running 1 file(s) with name pattern: ^\s?demo$
[18:16:14] The runner is starting because tests demo.test.ts were started due to a file change
[18:16:14] Enqueuing "demo"
[18:16:15] No task result for "demo", assuming the test just started running
[18:16:15] No errors found for "demo.test.ts"
[18:16:15] Marking "demo" as failed with 1 errors
[18:16:15] No errors found for "demo.test.ts"
[18:16:15] Ending test run demo.test.ts
[INFO 18:19:16] [API] Vitest process 19729 closed successfully
[INFO 18:19:16] [API] Running Vitest v2.1.1 (vitest-demo/vitest.config.ts) with Node.js@v20.15.1: /Users/dmitriy/.nvm/current/bin/node 
[INFO 18:19:16] [API] Vitest v2.1.1 (vitest-demo/vitest.config.ts) process 19845 created
[INFO 18:19:16] [API] Collecting tests: demo.test.ts
[18:19:16] Not starting the runner because tests are being collected
[18:19:16] There is no test run for "demo.test.ts"
[18:19:16] No test run to finish for demo.test.ts
[INFO 18:19:17] Running 1 file(s) with name pattern: ^\s?demo$
[18:19:17] The runner is starting because tests demo.test.ts were started due to a file change
[18:19:17] Enqueuing "demo"
[18:19:17] No task result for "demo", assuming the test just started running
[18:19:17] No errors found for "demo.test.ts"
[18:19:17] Marking "demo" as failed with 1 errors
[18:19:17] No errors found for "demo.test.ts"
[18:19:17] Ending test run demo.test.ts
[INFO 18:19:35] [API] Vitest process 19845 closed successfully
[INFO 18:19:35] [API] Running Vitest v2.1.1 (vitest-demo/vitest.config.ts) with Node.js@v20.15.1: /Users/dmitriy/.nvm/current/bin/node 
[INFO 18:19:35] [API] Vitest v2.1.1 (vitest-demo/vitest.config.ts) process 19879 created
[INFO 18:19:35] [API] Collecting tests: demo.test.ts
[18:19:35] Not starting the runner because tests are being collected
[18:19:35] There is no test run for "demo.test.ts"
[18:19:35] No test run to finish for demo.test.ts
[INFO 18:20:15] [API] Vitest process 19879 closed successfully
[INFO 18:20:15] [API] Running Vitest v2.1.1 (vitest-demo/vitest.config.ts) with Node.js@v20.15.1: /Users/dmitriy/.nvm/current/bin/node 
[INFO 18:20:15] [API] Vitest v2.1.1 (vitest-demo/vitest.config.ts) process 19922 created
[INFO 18:20:15] [API] Collecting tests: demo.test.ts
[18:20:15] Not starting the runner because tests are being collected
[18:20:15] There is no test run for "demo.test.ts"
[18:20:15] No test run to finish for demo.test.ts
[INFO 18:20:16] [API] Vitest process 19922 closed successfully
[INFO 18:20:16] [API] Running Vitest v2.1.1 (vitest-demo/vitest.config.ts) with Node.js@v20.15.1: /Users/dmitriy/.nvm/current/bin/node 
[INFO 18:20:16] [API] Vitest v2.1.1 (vitest-demo/vitest.config.ts) process 19942 created
[INFO 18:20:16] [API] Collecting tests: demo.test.ts
[18:20:16] Not starting the runner because tests are being collected
[18:20:17] There is no test run for "demo.test.ts"
[18:20:17] No test run to finish for demo.test.ts
[INFO 18:20:17] [API] Collecting tests: demo.test.ts
[18:20:17] Not starting the runner because tests are being collected
[18:20:17] There is no test run for "demo.test.ts"
[18:20:17] No test run to finish for demo.test.ts
[INFO 18:20:18] Running all tests in vitest-demo
[18:20:18] The runner is starting because tests demo.test.ts were started due to a file change
[18:20:18] Enqueuing "demo.test.ts"
[18:20:18] Enqueuing "demo"
[18:20:18] No task result for "demo", assuming the test just started running
[18:20:18] No errors found for "demo.test.ts"
[18:20:18] Marking "demo" as failed with 1 errors
[18:20:18] No errors found for "demo.test.ts"
[18:20:18] Ending test run demo.test.ts

Version

1.2.17

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-nice-to-haveNot breaking anything but nice to have (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions