Skip to content

jest extended snapshot matchers don't work with snapshot name #22

@sparten11740

Description

@sparten11740

Jest allows passing a snapshot name to snapshot matchers such as toMatchSnapshot and co, e.g.

expect(obj).toMatchSnapshot('inital state')
expect(obj).toMatchSnapshot('state after reload')

The full test name in that case is suffixed with : ${hint}.

exodus-test always assumes the passed argument to be a property matcher and disregards the overloaded signature
https://github.com/ExodusMovement/test/blob/eec3fa51c377cf1f075c23b32019f1907b7b055f/src/jest.snapshot.js#L113-L120

So before even attempting to extract the snapshot from the snapshot file, exodus-test throws in this line because it passes a string to toMatchObject

for reference, these are the supported signatures in jest

{
  toMatchSnapshot<U extends { [P in keyof T]: any }>(propertyMatchers: Partial<U>, snapshotName?: string): R;
  toMatchSnapshot(snapshotName?: string): R;
}

Metadata

Metadata

Assignees

No one assigned

    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