Questions tagged [snapshot-testing]

A mechanism to assist automated unit testing of visual components by generating a 'snapshot' of the component and then comparing the rendered component with the saved snapshot.

Snapshot testing was popularised by test frameworks like Jest, used to test React components in isolation. The test framework renders a 'snapshot' to a static file and then, in subsequent tests, the newly rendered component is compared to the saved snapshot. This saves a lot of test development effort.

52 questions
1
vote
1 answer

React Jest snapshot tests fail when --coverage flag enabled

I have built a React app (v16.13.1) and am testing it with Jest (v25.1.0). When I run npm test the tests all pass fine, but when I run npm test -- --coverage all of the components return undefined and all of the snapshot tests fail. It's happening…
Dave Sag
  • 13,266
  • 14
  • 86
  • 134
0
votes
0 answers

How to create and compare syrupy snapshots in hypothesis's stateful testing?

I want to create a hypothesis.stateful.RuleBasedStateMachine to run stateful testing in Python. When the test is running, I want it to be deterministic and either update some snapshots or compare with existing, so that I can manually review whether…
0
votes
1 answer

Jest snapshot test fails with @mui/x-date-pickers, different timestamp in Snapshot

We updated to the latest Mui Date picker. And now we have a strange Problem with a failing snapshot test in our CI pipeline. In our Jest Test, we set a fixed Date like this: jest.useFakeTimers().setSystemTime(new Date('04 Dec 1995 00:12:00…
0
votes
0 answers

pytest_snapshot snaphot removal

If I have a tests folder structure like this -tests --init.py --test_main.py And my test looks like this: from pytest_snapshot.plugin import Snapshot def test_my_func(snapshot: Snapshot) -> None: output = "test output" …
Erik
  • 722
  • 4
  • 11
0
votes
0 answers

Paparazzi running ./gradlew testDebug verifyPaparazziDebug does not generate report htlm

I tried to run Paparazzi snapshot tests via terminal using these commands: ./gradlew clean assembleDebug testDebug verifyPaparazziDebug But this seems to skip testDebug. It is supposed to generate index.htlm in /app/build/reports/paparazzi/ folder…
Marat
  • 6,142
  • 6
  • 39
  • 67
0
votes
0 answers

error- toMatchSnapshot() must be called during the test (playwright + ts)

In project I used playwright + typescript + cucumber. I have problem with comparing screenshots using 'toMatchSnapshot()' method. In definition steps file I used it like that expect(await…
0
votes
1 answer

Override accessibility environment values in SwiftUI snapshot tests?

I'm writing snapshot tests for SwiftUI views using the Point-Free snapshot test library. I'd like to test that my views respond correctly to the following SwiftUI environment…
Zev Eisenberg
  • 8,080
  • 5
  • 38
  • 82
0
votes
0 answers

Snapshot test React Native (Android)

I am trying to do a Snapshot test in React Native for Android, but I am running into an error: As soon as I include Dimensions into my setupFiles I get this error. @react-native-firebase/app is included in transformIgnorePatterns. How can I fix this…
0
votes
0 answers

How to test fluent's mergeStyleSets() without snapshots

We're moving away from Enzyme and onto react-testing-library. In one of our components, we're using a prop to decide a paddingTop value. That gets passed down the component chain which eventually gets included in a mergeStyleSets() call from…
benjamin.keen
  • 1,936
  • 1
  • 20
  • 29
0
votes
0 answers

Jest TransformIgnorePatterns causes other unrelated tests to fail

i am testing a typescript react app using jest and react testing library which I'm new to. I introduced d3 and the tests related kept failing and the error was : Jest encountered an unexpected token - SyntaxError: Unexpected token. I found the…
someone
  • 1
  • 2
0
votes
0 answers

Can I make jest fail on missing snapshots?

I would like to ensure, that I always commit my snapshot files and none are missing in my repository. Currently when I do not commit a snapshot file, my build on the CI does not fail because it only fails on a mismatch, and would just generate the…
peach
  • 657
  • 5
  • 26
0
votes
1 answer

How to mock react-bootstrap components while doing snapshot testing in React?

I am working on a react project which is built using react-bootstrap UI. While there are a lot of options for writing test cases, I opted for Snapshot testing using Jest. I have a component which is wrapped inside a bootstrap Modal and is always…
Salvino D'sa
  • 4,018
  • 1
  • 7
  • 19
0
votes
0 answers

How to wait for the first sink to get called before running a snapshot test

I'm running into an issue with snapshot testing a view that listens for updates from a view model using a Combine publisher. The issue seems to be with the sink that is received on the main queue - the closure is what updates the view state. When I…
0
votes
1 answer

.Net Core Snapshot unit testing - Verify does not serialize Newtonsoft.Json JObject

I try to use Verify to write a snapshot unit test to test a complex object. However, Newtonsoft.Json JObject properties are serialized into an empty array. Verify version is 19.6.0. How to make Verify to serialize JObject properly? Code to…
Mykola
  • 197
  • 1
  • 10
0
votes
0 answers

Browser not Defined error in Jest-Image-Snapshot Testing in React

I want to implement https://github.com/americanexpress/jest-image-snapshot#-api in my React application and tried writing one of the test cases but gives me an error saying the browser is not defined when trying to run a test using the command "npm…