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

Updating an inline snapshot writes to file but not to open editor #2761

Closed
ncirkel opened this issue Jul 31, 2021 · 5 comments
Closed

Updating an inline snapshot writes to file but not to open editor #2761

ncirkel opened this issue Jul 31, 2021 · 5 comments
Labels

Comments

@ncirkel
Copy link

ncirkel commented Jul 31, 2021

Issue description or question

I tend to have many unsaved files open when working with unit tests in VSCode. This is made possible by Wallaby detecting and running unsaved changes.

One thing I keep running into is having to save a file before updating inline snapshots. The update is written to the file on disk, but the open editor is unchanged. Wallaby reports all green on the outdated code and when trying to save, VSCode complains that the content of the file on disk is newer.

This also happens when typing expect([...]).toMatchInlineSnapshot(), which triggers inserting the initial snapshot. I have to remember to quickly save the file before it updates.

I could certainly live with Wallaby saving the file before updating snapshots, if that's the easy solution to this.

Wallaby diagnostics report

(The relevant bit)

{
  editorVersion: '1.58.2',
  pluginVersion: '1.0.301',
  editorType: 'VSCode',
  osVersion: 'win32 10.0.22000',
  nodeVersion: 'v14.17.1',
  coreVersion: '1.0.1118',
  checksum: 'N2RiOWMyYjdlOGYyMTQ1MDE4NmY1NWU3ZTY1MDU3NWUsMTY0NDcxMDQwMDAwMCww',
}
@smcenlly
Copy link
Member

smcenlly commented Aug 2, 2021

Currently, Wallaby does not work properly with inline snapshots in some editors when not using auto-save. We are working on improving this behaviour and expect to have an updated version that correctly works when not using auto-save by the end of this week. We will reply to this issue when the updated version is available.

@smcenlly smcenlly added the bug label Aug 2, 2021
@ncirkel
Copy link
Author

ncirkel commented Aug 3, 2021

That's fantastic, looking forward!

@smcenlly
Copy link
Member

smcenlly commented Aug 3, 2021

We have updated Wallaby to better handle updating inline snapshots in unsaved files. Please update to the latest version of Wallaby and it will work without the problem that you identified.

@smcenlly smcenlly closed this as completed Aug 3, 2021
@ncirkel
Copy link
Author

ncirkel commented Aug 6, 2021

I had time to try this now and, unfortunately, something goes wrong on my end. Updating an inline snapshot in an unsaved file results in a test run failure. This is from the log:

[Info]  console.log: Jest: FAIL packages/ui/src/editor/state/array/array.test.tsx
[Info]  console.log: Jest:   ● Test suite failed to run
[Info]      Jest: Couldn't locate all inline snapshots.
[Info]        at Object.parse (node_modules/jest-snapshot/build/InlineSnapshots.js:267:11)
[Info]        at Object.parse (node_modules/prettier/index.js:13625:19)
[Info]        at coreFormat (node_modules/prettier/index.js:14899:14)
[Info]        at format (node_modules/prettier/index.js:15131:14)
[Info]        at node_modules/prettier/index.js:57542:12
[Info]        at Object.format (node_modules/prettier/index.js:57562:12)
[Error] Runtime error: undefined 

Diagnostics report:

{
  editorVersion: '1.59.0',
  pluginVersion: '1.0.302',
  editorType: 'VSCode',
  osVersion: 'win32 10.0.19043',
  nodeVersion: 'v12.22.1',
  coreVersion: '1.0.1125',
  checksum: 'N2RiOWMyYjdlOGYyMTQ1MDE4NmY1NWU3ZTY1MDU3NWUsMTY0NDcxMDQwMDAwMCww',
}

@smcenlly
Copy link
Member

smcenlly commented Aug 6, 2021

@ncirkel - this doesn't sound related to our change; the change that we made is actually downstream of this call and should be completely unrelated.

Are you able to create a simple sample repo and step-by-step instructions so that we can replicate the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants