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

TypeError: actual.match is not a function #5513

Closed
6 tasks done
ShooTeX opened this issue Apr 9, 2024 · 3 comments
Closed
6 tasks done

TypeError: actual.match is not a function #5513

ShooTeX opened this issue Apr 9, 2024 · 3 comments

Comments

@ShooTeX
Copy link

ShooTeX commented Apr 9, 2024

Describe the bug

Pre 1.4.0 we were testing promises that were rejected with Error using:

await expect(rejectedPromise).rejects.toMatch(/invalid/);

but now it's throwing:

TypeError: actual.match is not a function

Using toThrow() instead fixes the issue.
I'm not sure if the error is expected but the message is not really helpful.

This is probably related to #5267.

Reproduction

v1.4.0

v1.3.1

System Info

System:
    OS: macOS 14.4.1
    CPU: (12) arm64 Apple M2 Pro
    Memory: 4.16 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.7.2 - /opt/homebrew/bin/node
    Yarn: 1.22.22 - /etc/profiles/per-user/*/bin/yarn
    npm: 10.5.0 - /opt/homebrew/bin/npm
    pnpm: 8.15.5 - /etc/profiles/per-user/*/bin/pnpm
    bun: 1.0.35 - /etc/profiles/per-user/*/bin/bun
  Browsers:
    Chrome: 123.0.6312.107
    Safari: 17.4.1

Used Package Manager

npm

Validations

@ShooTeX
Copy link
Author

ShooTeX commented Apr 9, 2024

sorry, for some reason I didn't see #5428 is this possibly already fixed?

edit: The fix seems to be a more descriptive error, but for our case it is a breaking change since the test was passing in 1.3.1. Not sure if intended.

@sheremet-va
Copy link
Member

sorry, for some reason I didn't see #5428 is this possibly already fixed?

edit: The fix seems to be a more descriptive error, but for our case it is a breaking change since the test was passing in 1.3.1. Not sure if intended.

Yeah, this was fixed but not released yet. 1.5.0 should be released this week.

@hi-ogawa
Copy link
Contributor

The fix seems to be a more descriptive error, but for our case it is a breaking change since the test was passing in 1.3.1. Not sure if intended.

Hmm, right, I didn't notice at all, but this is technically a breaking change. Previously we were using chai assertion this.match(expected), which covers many cases like Error example you had, but now I changed it to simple string.match(expected).

Depending on the report (now already two from your case and also from btea's case), we might need to consider making it more aligned with original chai assertion.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2024
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

3 participants