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
0 answers

Android Snapshot test GithUb Action

I have the following yaml file: name: Test and check build on: push: branches: [ "main", "dev" ] pull_request: branches: [ "main", "dev", "hotfix" ] jobs: build: runs-on: macos-latest if: github.event.pull_request.draft ==…
1048576
  • 615
  • 9
  • 27
1
vote
1 answer

When running a snapshot test with Verify an exception is thrown because the verified.txt.bak file is still there

I'm using Verify.Xunit (version 19.11.2) in a .NET 6 xUnit test project. Tests are running in the Rider IDE. To do the Verify actual/expected string comparison Verify uses WinMerge. Sometimes (more often than not) when running a test the temporary…
1
vote
0 answers

Azure Devops Swift Snapshot Tests succeeding while fail expected

We've been using swift-snapshot for a while now and locally everything seems to work correctly. We host our source on Azure Devops and manage our CI/CD there. We've checked in our Snapshots (isRecording = true) in main. I've modified the source code…
Mittchel
  • 1,896
  • 3
  • 19
  • 37
1
vote
0 answers

How to configure visual regression testing using Loki for Angular and Web components in Storybook

We have a design system with the core components built on Stencil and cross-compiled across React and Angular frameworks. Ideally we have all the components in React, Angular and Web-components. We use storybook as Component explorer. Now that we…
1
vote
1 answer

Property 'toMatchSnapshot' does not exist on type 'Assertion'

I am using CRA to build a web app that also uses Typescript, and Jest for (snapshot) testing. I am randomly now getting the error Property 'toMatchSnapshot' does not exist on type 'Assertion'. across all my snapshot tests. Here is an example test…
Benji
  • 45
  • 8
1
vote
1 answer

CombinationApprovals.VerifyAllCombinations equiavalent using Verify?

Does the Verify library offer Combination Approvals and how would a sample one be implemented? I would like to implement something like: CombinationApprovals.VerifyAllCombinations( DoUpdateQuality, new string[] { "foo", "Aged Brie",…
1
vote
0 answers

SnapshotTesting adds random top padding for SwiftUI views

I'm trying to write some Snapshot tests using SnapshotTesting for my SwiftUI views. If I use .image(layout: .device(config: .iPhone8Plus)) my view gets an extra padding at the top as shown in the first image. This is using an M1 Mac with Xcode on…
danialzahid94
  • 4,103
  • 2
  • 19
  • 31
1
vote
0 answers

SwiftUI Snapshot test async view

I am following this page in creating a wrapped HStack. However, the HStack asynchronously calculates its height, which means my snapshot testing become really funky. I looked at this episode on asynchronous snapshot testing but it wasn't too…
skywalkerdude
  • 117
  • 1
  • 8
1
vote
1 answer

How to ignore style changes in styled-components during snapshot tests in jest

Assume i have a simple component I wish to snapshot test: const Component = styled.div`{ color: red; }` My snapshot test wishes to ensure that the div renders, but the styling is not important. So if I did a snapshot test on this Component, and i…
plusheen
  • 1,128
  • 1
  • 8
  • 23
1
vote
0 answers

What does the "1" in the jest snapshots mean?

What does the number 1 in jest snapshots signify? For example this is a code snippet from their docs and I'd like to understand what the number 1 in the first line of code means: // Snapshot exports[`will fail every time 1`] = ` Object { …
1
vote
1 answer

How to render plain html code with react-test-renderer or other alternative libs?

react-test-renderer's to JSON function returns React structure instead of plain html code. For example: import "./styles.css"; import renderer from 'react-test-renderer' const Test1 = () => Hello World! const Test2 = () =>
1
vote
0 answers

iOS UI snapshot testing how to have different Reference Images folder for multiple targets

I have a project with 4 targets, since it's a whitelabel app, basically most of the code is common, except the branding (images, colors etc). I'm trying to set up UI Snapshots tests for each, but I want to avoid having duplicated code as well, so I…
Irina DM
  • 61
  • 3
1
vote
0 answers

Is there any way to render correctly a RichText to create a golden test?

I tried to create a golden test with specific text to validate, but when the screen contains a RichText the component is not correctly rendered. Is there any way to render this? Image with Text and RichText on the same screen - RichText is…
1
vote
0 answers

Jest Vue failing: SyntaxError: Unexpected token 'export'

I have sucessfully setup Jest with Quasar and Vue and most of my tests work. The only test that is failing is this one because of the following error message Jest encountered an unexpected token This usually means that you are trying to import a…
myoda999
  • 335
  • 2
  • 11
1
vote
0 answers

shallow render styled components with css and snapshot testing

I'm using styled components and jest+enzyme+jest-styled-components to test my components. I want to be able to shallow render components and use snapshot testing: const wrapper = shallow(ASDF); …
Jenian
  • 552
  • 1
  • 5
  • 18