{"name":"@vitest/snapshot","version":"0.31.0","license":"MIT","_id":"@vitest/snapshot@0.31.0","maintainers":[{"name":"oreanno","email":"foxzdavinci@gmail.com"},{"name":"patak","email":"matias.capeletto@gmail.com"},{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"homepage":"https://github.com/vitest-dev/vitest/tree/main/packages/snapshot#readme","bugs":{"url":"https://github.com/vitest-dev/vitest/issues"},"dist":{"shasum":"f59c4bcf0d03f1f494ee09286965e60a1e0cab64","tarball":"http://registry-npm.ywwl.com/@vitest/snapshot/download/@vitest/snapshot-0.31.0.tgz","fileCount":14,"integrity":"sha512-5dTXhbHnyUMTMOujZPB0wjFjQ6q5x9c8TvAsSPUNKjp1tVU7i9pbqcKPqntyu2oXtmVxKbuHCqrOd+Ft60r4tg==","signatures":[{"sig":"MEUCIFAJTMwKqsl80HnDTV4Cp+9L6jRclAa2WRmeXACxLO7IAiEAwSJrQfcUhaJjNv0RT4YEtjA8Rcfvux2IGhQizBXsCe8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":75357,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkUqMyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoIhw/7Bukf+gGVq8yZOKZFTzwofgoQQGI+yryStDn49nEQeBII21wX\r\nZ14iJZtzp/JjidqsHa2u1Us7bxoPx5L6XSp1wdalbAuGhL591d5jhChSlSkh\r\nTSF6/a00oaQkDPGEgzLTVHWob11FBnvUwY36xXY5ojPrJz4Koovm4h+i+8dg\r\nqzaWYuEhkvk0+prI78WUjZMSxs66FdGZOO1VXMMnAB4YKnoxvq2Ua9nliSK/\r\nZefqP9fGLlk1WpI2iG/V5YMQ8rukTVT7RAxfCi5KEuIQAojcgWdTjABEX9ao\r\neLRtjYAXU+2Srdf+YhH0I8j4J8P4U2V7VIICJBMxKQJvgHJmerOngmx+v2N8\r\n+/nQm5wsKiJNlEMoT1qIDJjaGWD/yE7boltlooR/ZkLaK4CtNEouiHHSBKk2\r\nwdxQHMh89lVV90DflCFZgmKfP/1lpyjHRC2XXLNXEvoAY96dhJs/kOXzNVG1\r\nHtIB/yyTGA8dno5Cn31ba0/7H+CWlwdRpdVtY0nrxLXlviYs4S97wNyAzhWR\r\n/GqTuQaGGjjSRwxG7XQ631gmPrs2KOYz7YEH/4P9C2K/WKpwBhvI9/U9/D7P\r\nhbjr5cpM5fxLqicjJ9y2M6ZXyZPVTKWmDYc9kJsMuT6lQbOvgNQxz9YJdEIc\r\nI7cudxrnYGXWWD+gShRgQY7TkoiCdbrmqq8=\r\n=nNxk\r\n-----END PGP SIGNATURE-----\r\n","size":13368,"noattachment":false,"key":"/@vitest/snapshot/-/@vitest/snapshot-0.31.0.tgz"},"main":"./dist/index.js","type":"module","_from":"file:vitest-snapshot-0.31.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./*":"./*","./manager":{"types":"./dist/manager.d.ts","import":"./dist/manager.js"},"./environment":{"types":"./dist/environment.d.ts","import":"./dist/environment.js"}},"funding":"https://opencollective.com/vitest","scripts":{"dev":"rollup -c --watch","build":"rimraf dist && rollup -c"},"_npmUser":{"name":"oreanno","email":"foxzdavinci@gmail.com"},"_resolved":"/private/var/folders/vt/_y31xx1x41j89s4svb4fnhfw0000gn/T/703b5f7082a741b6235c27cdacb6e5d6/vitest-snapshot-0.31.0.tgz","_integrity":"sha512-5dTXhbHnyUMTMOujZPB0wjFjQ6q5x9c8TvAsSPUNKjp1tVU7i9pbqcKPqntyu2oXtmVxKbuHCqrOd+Ft60r4tg==","repository":{"url":"git+https://github.com/vitest-dev/vitest.git","type":"git","directory":"packages/snapshot"},"_npmVersion":"8.15.0","description":"Vitest snapshot manager","directories":{},"sideEffects":false,"_nodeVersion":"16.17.1","dependencies":{"pathe":"^1.1.0","magic-string":"^0.30.0","pretty-format":"^27.5.1"},"_hasShrinkwrap":false,"devDependencies":{"@vitest/utils":"0.31.0","natural-compare":"^1.4.0","@types/natural-compare":"^1.4.1"},"_npmOperationalInternal":{"tmp":"tmp/snapshot_0.31.0_1683137329856_0.7028323685047109","host":"s3://npm-registry-packages"},"readme":"# @vitest/snapshot\n\nLightweight implementation of Jest's snapshots.\n\n## Usage\n\n```js\nimport { SnapshotClient } from '@vitest/snapshot'\nimport { NodeSnapshotEnvironment } from '@vitest/snapshot/environment'\nimport { SnapshotManager } from '@vitest/snapshot/manager'\n\nconst client = new SnapshotClient({\n  // you need to provide your own equality check implementation if you use it\n  // this function is called when `.toMatchSnapshot({ property: 1 })` is called\n  isEqual: (received, expected) =>\n    equals(received, expected, [iterableEquality, subsetEquality]),\n})\n\n// class that implements snapshot saving and reading\n// by default uses fs module, but you can provide your own implementation depending on the environment\nconst environment = new NodeSnapshotEnvironment()\n\n// you need to implement this yourselves,\n// this depends on your runner\nfunction getCurrentFilepath() {\n  return '/file.spec.js'\n}\nfunction getCurrentTestName() {\n  return 'test1'\n}\n\n// example for inline snapshots, nothing is required to support regular snapshots,\n// just call `assert` with `isInline: false`\nfunction wrapper(received) {\n  function __INLINE_SNAPSHOT__(inlineSnapshot, message) {\n    client.assert({\n      received,\n      message,\n      isInline: true,\n      inlineSnapshot,\n      filepath: getCurrentFilepath(),\n      name: getCurrentTestName(),\n    })\n  }\n  return {\n    // the name is hard-coded, it should be inside another function, so Vitest can find the actual test file where it was called (parses call stack trace + 2)\n    // you can override this behaviour in SnapshotState's `_inferInlineSnapshotStack` method by providing your own SnapshotState to SnapshotClient constructor\n    toMatchInlineSnapshot: (...args) => __INLINE_SNAPSHOT__(...args),\n  }\n}\n\nconst options = {\n  updateSnapshot: 'new',\n  snapshotEnvironment: environment,\n}\n\nawait client.startCurrentRun(\n  getCurrentFilepath(),\n  getCurrentTestName(),\n  options\n)\n\n// this will save snapshot to a file which is returned by \"snapshotEnvironment.resolvePath\"\nclient.assert({\n  received: 'some text',\n  isInline: false,\n})\n\n// uses \"pretty-format\", so it requires quotes\n// also naming is hard-coded when parsing test files\nwrapper('text 1').toMatchInlineSnapshot()\nwrapper('text 2').toMatchInlineSnapshot('\"text 2\"')\n\nconst result = await client.finishCurrentRun() // this saves files and returns SnapshotResult\n\n// you can use manager to manage several clients\nconst manager = new SnapshotManager(options)\nmanager.add(result)\n\n// do something\n// and then read the summary\n\nconsole.log(manager.summary)\n```\n","publish_time":1683137330116,"_cnpm_publish_time":1683137330116,"dist-tags":{"beta":"5.1.0-beta.1","latest":"5.1.0","rc":"5.0.0-rc.4","V3":"3.2.7","V4":"4.1.12"}}