Archived
1
0
This repository has been archived on 2023-05-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
home-page/node_modules/eslint-plugin-jest/docs/rules/prefer-inline-snapshots.md
Sean Edmunds 0584430b5c First commit
2021-12-13 17:00:40 -06:00

1.1 KiB

Suggest using inline snapshots (prefer-inline-snapshots)

Deprecated

This rule has been deprecated in favor of no-restricted-matchers with the following config:

{
  "rules": {
    "jest/no-restricted-matchers": [
      "error",
      {
        "toThrowErrorMatchingSnapshot": "Use `toThrowErrorMatchingInlineSnapshot()` instead",
        "toMatchSnapshot": "Use `toMatchInlineSnapshot()` instead"
      }
    ]
  }
}

In order to make snapshot tests more manageable and reviewable toMatchInlineSnapshot() and toThrowErrorMatchingInlineSnapshot should be used to write the snapshots' inline in the test file.

Rule details

This rule triggers a warning if toMatchSnapshot() or toThrowErrorMatchingSnapshot is used to capture a snapshot.

The following pattern is considered warning:

expect(obj).toMatchSnapshot();
expect(error).toThrowErrorMatchingSnapshot();

The following pattern is not warning:

expect(obj).toMatchInlineSnapshot();
expect(error).toThrowErrorMatchingInlineSnapshot();