Skip to content

Convert existing tests to snapshot tests using syrupy #2023

@sydduckworth

Description

@sydduckworth

syrupy is a snapshot testing library for Python that allows you to create snapshots of arbitrary data and verify that your test output matches the expected result.

syrupy will be added as a test dependency in the near future (PR #2014) and will initially only be used to test the output of the updated info commands in the PR.
However, there are many existing tests that could benefit from using snapshots:

  • A lot of the existing tests for the info command and functions currently check for the present of a specific word or phrase in the output. Switching these tests to use snapshots would make them less verbose and more thorough. There are probably other tests that also use this pattern.
  • The tests for the diff command are essentially implementing their own custom snapshot functionality which could be replaced with syrupy snapshots.

Technically, anywhere where we're comparing a computed value to a constant value can be replaced with a snapshot.
Obviously there are places where we don't want to do that because the computed value has some semantic meaning, and keeping the constant in the test itself makes it more clear what we're actually testing.
In some cases, though, it is more concise and probably more maintainable to replace the constants with automatically generated snapshots. For example, there are many, many tests that check the value of a block's checksum which are currently storing the checksum in the test itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions