From d9a42e5ba5e0393717e27e249d849a6464c0dbce Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Fri, 8 Sep 2023 15:32:58 +0300 Subject: [PATCH] chore: add snapshot example --- packages/snapshot/README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/snapshot/README.md b/packages/snapshot/README.md index 541712b36067..82643f412c5b 100644 --- a/packages/snapshot/README.md +++ b/packages/snapshot/README.md @@ -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' } @@ -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(), }) @@ -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()