Skip to content

Commit

Permalink
chore: add snapshot example
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Sep 27, 2023
1 parent 4542cdd commit d9a42e5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/snapshot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const client = new SnapshotClient({
// by default uses fs module, but you can provide your own implementation depending on the environment
const environment = new NodeSnapshotEnvironment()

// you need to implement this yourselves,
// this depends on your runner
function getCurrentFilepath() {
return '/file.spec.ts'
}
Expand All @@ -35,8 +37,6 @@ function wrapper(received) {
message,
isInline: true,
inlineSnapshot,
// you need to implement this yourselves,
// this depends on your runner
filepath: getCurrentFilepath(),
name: getCurrentTestName(),
})
Expand All @@ -55,6 +55,12 @@ const options = {

await client.startCurrentRun(getCurrentFilepath(), getCurrentTestName(), options)

// this will save snapshot to a file which is returned by "snapshotEnvironment.resolvePath"
client.assert({
received: 'some text',
isInline: false,
})

// uses "pretty-format", so it requires quotes
// also naming is hard-coded when parsing test files
wrapper('text 1').toMatchInlineSnapshot()
Expand Down

0 comments on commit d9a42e5

Please sign in to comment.