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

Error locations are already converted from URLs to paths by Jest #55

Merged
merged 1 commit into from Aug 27, 2022

Conversation

nicolo-ribaudo
Copy link
Owner

@nicolo-ribaudo nicolo-ribaudo commented Aug 24, 2022

Fixes babel/babel#14867 (comment)

@fisker Do you use inline snapshots in Prettier, and if yes did you ever had problems with the -u Jest options not working?

snapshotState._inlineSnapshots.forEach(({ frame }) => {
// When using native ESM, errors have a URL location.
// Jest expects paths.
frame.file = fileURLToPath(frame.file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If by any chance frame.file could be a URL, we can test if frame.file starts with file:// and then apply the transform.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was probably for an older Jest 27 version, we can just bump the peer dep requirement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jestjs/jest#12277, so 27.5 can be minimum if you don't wanna leave 27 behind 🙂

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@fisker
Copy link
Contributor

fisker commented Aug 24, 2022

Do you use inline snapshots in Prettier

Not sure , didn't notice that.

@fisker
Copy link
Contributor

fisker commented Aug 24, 2022

@liuxingbaoyu
Copy link
Contributor

When I was debugging jest 29.0 just now, I found that snapshotState._inlineSnapshots is always empty.

@nicolo-ribaudo nicolo-ribaudo merged commit fdeb841 into main Aug 27, 2022
@nicolo-ribaudo nicolo-ribaudo deleted the fix-snapshot-u branch August 27, 2022 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants