Search code examples
node.jstypescriptnestjssnapshot-testing

Node-tap Protocol updating a spec.ts.cjs snapshot


Using the example from node-tap-snapshot-examples, I created a snapshot using the command tap tagger.test.mjs --snapshot for the following test (Modified TS version).

// tagger.spec.ts
import t from 'tap'
import tagger from './tagger.spec.ts'
t.matchSnapshot(tagger('tagName', 'content'), 'output')

A snapshot CJS file is being created. Now when I update a test with another test, I will require an updated snapshot. I looked into the documentation and couldnt see a snapshot command for updating a snapshot. So I tried the same command after updating my test file with new tests. and as a result all I see is an error,

x must match snapshot

My question is how can I create or update a new snapshot? thanks!


Solution

  • Its a very easy solution.

    npm run tap -- --snapshot filename.spec.ts