jest-file-snapshot
Advanced tools
Comparing version 0.6.0 to 0.7.0
16
index.js
@@ -6,3 +6,3 @@ /* istanbul ignore file */ | ||
const chalk = require('chalk'); | ||
const diff = require('jest-diff').default; | ||
const { diff } = require('jest-diff'); | ||
const mkdirp = require('mkdirp'); | ||
@@ -28,2 +28,3 @@ const filenamify = require('filenamify'); | ||
* diff?: import('jest-diff').DiffOptions, | ||
* diffMethod?: (a: string, b: string, options: import('jest-diff').DiffOptions) => string, | ||
* fileExtension?: string, | ||
@@ -44,5 +45,9 @@ * }} options | ||
'__file_snapshots__', | ||
`${filenamify(this.currentTestName, { | ||
replacement: '-', | ||
}).replace(/\s/g, '-')}-${this.assertionCalls}` | ||
`${filenamify( | ||
this.currentTestName, | ||
{ | ||
replacement: '-', | ||
}, | ||
{ maxLength: Infinity } | ||
).replace(/\s/g, '-')}-${this.assertionCalls}` | ||
) + fileExtension | ||
@@ -118,6 +123,7 @@ : filepath; | ||
const diffMethod = options.diffMethod || diff; | ||
const difference = | ||
Buffer.isBuffer(content) || Buffer.isBuffer(output) | ||
? '' | ||
: `\n\n${diff(output, content, options.diff)}`; | ||
: `\n\n${diffMethod(output, content, options.diff)}`; | ||
@@ -124,0 +130,0 @@ return { |
{ | ||
"name": "jest-file-snapshot", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Jest matcher to write snapshots to a separate file instead of the default snapshot file used by Jest", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -47,2 +47,3 @@ # jest-file-snapshot | ||
- `diff`: options for [`jest-diff`](https://github.com/facebook/jest/tree/master/packages/jest-diff) | ||
- `fileExtension`: optional file extension to use for the snapshot file. | ||
@@ -49,0 +50,0 @@ You should also [exclude the output files from Jest's watcher](https://jestjs.io/docs/en/configuration#watchpathignorepatterns-arraystring) so that updating the snapshot doesn't re-run the tests again. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9813
162
89