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.getState().currentTestName incompatible with Jest #4874

Open
6 tasks done
programmer24601 opened this issue Jan 4, 2024 · 1 comment
Open
6 tasks done

expect.getState().currentTestName incompatible with Jest #4874

programmer24601 opened this issue Jan 4, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@programmer24601
Copy link

Describe the bug

When calling expect.getState().currentTestName Jest will return a string in the format:

`${describeTitle} ${testTitle}`

Whereas Vitest will produce:

`{filePath} > ${describeTitle} > ${testTitle}`

Although I prefer what Vitest produces, the inconsistency is causing issue with a jest matcher library jest-image-snapshot which relies on this API for generating filenames for snapshot image files. Migrating from jest to vitest is breaking my tests as the filenames being generated are too long resulting in a ENAMETOOLONG error.

My proposal would be to make this API consistent with Jest, and offer this richer output on a separate API (e.g. currentTestFullName).

Finally, I'm raising this as a bug as Vitest advertises itself as "Jest Compatible". This is an example that clearly breaks that contract.


Relates to #297

Reproduction

Reproduction not necessary.

System Info

vitest 1.1.1

Used Package Manager

npm

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Jan 4, 2024

Finally, I'm raising this as a bug as Vitest advertises itself as "Jest Compatible".

We have the whole migration page in docs for people moving away from Jest, we are compatible to the point it makes sense for us. It's been two years since the API you mentioned was implemented (and it's used in reporters, for example) and it might break other libraries that Vitest users rely on.

I'd say this qualifies as a separate section in the migration guide.

@sheremet-va sheremet-va added documentation Improvements or additions to documentation and removed pending triage labels Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants