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

expect.any and toHaveProperty are not working as expected #1675

Closed
6 tasks done
aneem opened this issue Jul 19, 2022 · 0 comments
Closed
6 tasks done

expect.any and toHaveProperty are not working as expected #1675

aneem opened this issue Jul 19, 2022 · 0 comments

Comments

@aneem
Copy link

aneem commented Jul 19, 2022

Describe the bug

This works with Jest:

expect({ str: 'abcd'}).toHaveProperty('str', expect.any(String));

Doesn't with Vitest:

❯ test/basic.test.ts:6:26
      4| 
      5| test('expect.any', () => {
      6|   expect({ str: 'abcd' }).toHaveProperty('str', expect…
       |                          ^
      7| });
      8| 

  - Expected   "Any<String>"
  + Received   "abcd"

CleanShot 2022-07-19 at 14 06 03@2x

Reproduction

https://stackblitz.com/edit/node-fhkkmq?file=test/basic.test.ts

System Info

System:
    OS: macOS 12.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 893.54 MB / 16.00 GB
    Shell: 3.4.1 - /usr/local/bin/fish
  Binaries:
    Node: 16.14.2 - ~/.asdf/installs/nodejs/16.14.2/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 8.5.0 - ~/.asdf/plugins/nodejs/shims/npm
    Watchman: 2022.05.30.00 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 101.1.38.119
    Chrome: 103.0.5060.114
    Firefox: 102.0
    Safari: 15.5
  npmPackages:
    vite: ^3.0.2 => 3.0.2
    vitest: ^0.18.1 => 0.18.1

Used Package Manager

npm

Validations

skarab42 added a commit to skarab42/vitest that referenced this issue Jul 19, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants