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
0
votes
1 answer

Creating snapshot tests with Vitest for Lit components

I see some tutorials with React but am unclear how this would work w/ Lit. Specifically is there something like the react-test-renderer but for Lit?
phamjamstudio
  • 93
  • 1
  • 5
0
votes
1 answer

UTF-8 BOM in received-files from Verify

I'm trying out https://github.com/VerifyTests/Verify for unit testing. It outputs snapshots in UTF-8 but does not include the UTF-8 byte order mark at the beginning of the received file. This makes my diff tool think the file is using the system…
0
votes
0 answers

jest-extended-snapshot: Property 'toVerifyAllCombinations' does not exist on type 'JestMatchersShape'

I am trying to write TypeScript for the first time in my life, and I want to use a testing library that can do snapshot testing, with combinations of parameters. I have already tried jest + jest-extended-snapshot. Code: function myFunction(aNumber,…
Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
0
votes
0 answers

How to take a screenshot in XCUITest during press&hold?

I need to take a screenshot in the middle of zoom/pan/rotate, i.e. I expect some code like this: element.startPressAndHold(.twoTouches) // at this point my app renders differently, so I capture a screenshot // for snapshot testing let shot =…
Paulius Liekis
  • 1,676
  • 3
  • 18
  • 26
0
votes
0 answers

snapshottest falsely passes for different content

I am trying to use snapshottest for some pytests in Python. The stored snapshot of correct behavior is (and where I suspect the problem lays) snapshots['test_some_unauthorized 1'] = GenericRepr('') def…
jave.web
  • 13,880
  • 12
  • 91
  • 125
0
votes
1 answer

What is the significance of 1 written in every export statement of a snapshot test?

Why 1 is written with export statement, like here renders correctly 1 exports[`renders correctly 1`] = `

Facebook

`;
0
votes
1 answer

Jest snapshot test adds a "_class" word into React HOC in snapshot on CI but not on my machine

I have a React component importing another React HOC. My React HOC: import { withRouter } from "react-router"; ... const InnerComponent: FC = (props): ReactElement => { ... } const withData = compose( graphql(SOME_QUERY, { props:…
schlingel
  • 1,514
  • 2
  • 15
  • 24
1 2 3
4