Skip to content

toMatchSnapshot(filepath) #4231

Closed
Closed
@vjeux

Description

@vjeux

The current jest snapshot tests are annoying in the context of jest (and I presume relay as well) because they put things inside of quotes and add some small wrapper code to make it parse as js and it generates those snapshots in some __ directory.

I've been thinking about this problem for a while and I think I finally have a solution: add the ability to specify the filename as an argument of toMatchSnapshot().

Current

/* file.js */
expect(value).toMatchSnapshot()
/* __snapshots__/file.js.snap */
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`file.js 1`] = `
value
`;

Suggestion

/* file.js */
expect(value).toMatchSnapshot('file.snap')
/* file.snap */
value

Discussion

I'm not 100% sure how to remove unused snapshot files when they are no longer in use.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions