Skip to content

Jest ignores obsolete file snapshots if there are inline snapshotsย #6655

@vlad-zhukov

Description

@vlad-zhukov

๐Ÿ› Bug Report

Jest ignores obsolete file snapshots if there are inline snapshots in this test.

To Reproduce

Steps to reproduce the behavior:

test('test', () => {
	expect('foo').toMatchSnapshot();
});
$ jest
 PASS  __tests__/test.js
  โœ“ test (3ms)

 โ€บ 1 snapshot written.
Snapshot Summary
 โ€บ 1 snapshot written from 1 test suite.

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   1 written, 1 total
Time:        2.244s
Ran all test suites.

Change the above test to use inline snapshots:

test('test', () => {
	expect('foo').toMatchInlineSnapshot();
});
$ jest
 PASS  __tests__/test.js
  โœ“ test (3ms)

 โ€บ 1 snapshot written.
Snapshot Summary
 โ€บ 1 snapshot written from 1 test suite.

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   1 written, 1 total
Time:        2.302s
Ran all test suites.

Now both a file and an inline snapshots exists. The file snapshot is completely ignored, Jest doesn't report that it's obsolete and doesn't remove it with jest -u.

Expected behavior

Jest should fail on obsolete snapshots and remove them with jest -u.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions