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

Snapshot detection still not working in Vitest 3.0 #575

Closed
4 tasks done
ffMathy opened this issue Jan 21, 2025 · 0 comments
Closed
4 tasks done

Snapshot detection still not working in Vitest 3.0 #575

ffMathy opened this issue Jan 21, 2025 · 0 comments

Comments

@ffMathy
Copy link
Collaborator

ffMathy commented Jan 21, 2025

Describe the bug

In issue #527 (comment), @hi-ogawa kindly provided an example of some code that should be possible in Vitest 2.2 and higher. Since 3.0 is the new 2.2, I thought this would apply as well.

Reproduction

Use the following global setup file:

import type { SnapshotUpdateState } from 'vitest';
import type { TestProject } from 'vitest/node';

export default function setup(ctx: TestProject) {
  ctx.provide(
    'config:updateSnapshot',
    ctx.serializedConfig.snapshotOptions.updateSnapshot
  );
  ctx.onTestsRerun(() => {
    ctx.provide(
      'config:updateSnapshot',
      ctx.serializedConfig.snapshotOptions.updateSnapshot
    );
  });
}

declare module 'vitest' {
  export interface ProvidedContext {
    'config:updateSnapshot': SnapshotUpdateState;
  }
}

Now run your test. If you run vitest --update from the command-line, it properly provides the value "all". If you run vitest from the command-line, it properly provides the value "new".

But if you run "Update snapshot" from VS Code (by right-clicking on a test), it always provides the value "new". So something is causing it to not display the correct value ("all").

Output

N/A for this type of issue.

Extension Version

1.10.3

Vitest Version

vitest/3.0.0 linux-arm64 node-v23.5.0

Validations

@ffMathy ffMathy changed the title Snapshot detection still not working in Vitest 3.0.2 Snapshot detection still not working in Vitest 3.0 Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant