@jest/snapshot-utils
Advanced tools
+1
-1
@@ -82,3 +82,3 @@ /*! | ||
| const SNAPSHOT_VERSION = exports.SNAPSHOT_VERSION = '1'; | ||
| const SNAPSHOT_HEADER_REGEXP = /^\/\/ Jest Snapshot v(.+), (.+)\n/; | ||
| const SNAPSHOT_HEADER_REGEXP = /^\/\/ Jest Snapshot v(.+), (.+)\r?\n/; | ||
| const SNAPSHOT_GUIDE_LINK = exports.SNAPSHOT_GUIDE_LINK = 'https://jestjs.io/docs/snapshot-testing'; | ||
@@ -85,0 +85,0 @@ const SNAPSHOT_VERSION_WARNING = exports.SNAPSHOT_VERSION_WARNING = _chalk.default.yellow(`${_chalk.default.bold('Warning')}: Before you upgrade snapshots, ` + 'we recommend that you revert any local changes to tests or other code, ' + 'to ensure that you do not store invalid state.'); |
+2
-2
| { | ||
| "name": "@jest/snapshot-utils", | ||
| "version": "30.1.0", | ||
| "version": "30.1.1", | ||
| "repository": { | ||
@@ -37,3 +37,3 @@ "type": "git", | ||
| }, | ||
| "gitHead": "4d5f41d0885c1d9630c81b4fd47f74ab0615e18f" | ||
| "gitHead": "d347c0f3f87f976a1dbd9761d503e45f5ced2a7e" | ||
| } |
@@ -138,24 +138,30 @@ /** | ||
| test('getSnapshotData() throws for newer snapshot version', () => { | ||
| const filename = path.join(__dirname, 'old-snapshot.snap'); | ||
| jest | ||
| .mocked(fs.readFileSync) | ||
| .mockReturnValue( | ||
| `// Jest Snapshot v2, ${SNAPSHOT_GUIDE_LINK}\n\n` + | ||
| 'exports[`myKey`] = `<div>\n</div>`;\n', | ||
| test.each([ | ||
| ['Linux', '\n'], | ||
| ['Windows', '\r\n'], | ||
| ])( | ||
| 'getSnapshotData() throws for newer snapshot version with %s line endings', | ||
| (_: string, fileEol: string) => { | ||
| const filename = path.join(__dirname, 'old-snapshot.snap'); | ||
| jest | ||
| .mocked(fs.readFileSync) | ||
| .mockReturnValue( | ||
| `// Jest Snapshot v2, ${SNAPSHOT_GUIDE_LINK}${fileEol}${fileEol}` + | ||
| `exports[\`myKey\`] = \`<div>${fileEol}</div>\`;${fileEol}`, | ||
| ); | ||
| const update = 'none'; | ||
| expect(() => getSnapshotData(filename, update)).toThrow( | ||
| `${chalk.red( | ||
| `${chalk.red.bold('Outdated Jest version')}: The version of this ` + | ||
| 'snapshot file indicates that this project is meant to be used ' + | ||
| 'with a newer version of Jest. ' + | ||
| 'The snapshot file version ensures that all developers on a project ' + | ||
| 'are using the same version of Jest. ' + | ||
| 'Please update your version of Jest and re-run the tests.', | ||
| )}\n\nExpected: v${SNAPSHOT_VERSION}\nReceived: v2`, | ||
| ); | ||
| const update = 'none'; | ||
| }, | ||
| ); | ||
| expect(() => getSnapshotData(filename, update)).toThrow( | ||
| `${chalk.red( | ||
| `${chalk.red.bold('Outdated Jest version')}: The version of this ` + | ||
| 'snapshot file indicates that this project is meant to be used ' + | ||
| 'with a newer version of Jest. ' + | ||
| 'The snapshot file version ensures that all developers on a project ' + | ||
| 'are using the same version of Jest. ' + | ||
| 'Please update your version of Jest and re-run the tests.', | ||
| )}\n\nExpected: v${SNAPSHOT_VERSION}\nReceived: v2`, | ||
| ); | ||
| }); | ||
| test('getSnapshotData() throws for deprecated snapshot guide link', () => { | ||
@@ -174,3 +180,5 @@ const deprecatedGuideLink = 'https://goo.gl/fbAQLP'; | ||
| `${chalk.red( | ||
| `${chalk.red.bold('Outdated guide link')}: The snapshot guide link is outdated.` + | ||
| `${chalk.red.bold( | ||
| 'Outdated guide link', | ||
| )}: The snapshot guide link is outdated.` + | ||
| 'Please update all snapshots while upgrading of Jest', | ||
@@ -177,0 +185,0 @@ )}\n\nExpected: ${SNAPSHOT_GUIDE_LINK}\n` + |
+4
-2
@@ -16,3 +16,3 @@ /** | ||
| export const SNAPSHOT_VERSION = '1'; | ||
| const SNAPSHOT_HEADER_REGEXP = /^\/\/ Jest Snapshot v(.+), (.+)\n/; | ||
| const SNAPSHOT_HEADER_REGEXP = /^\/\/ Jest Snapshot v(.+), (.+)\r?\n/; | ||
| export const SNAPSHOT_GUIDE_LINK = 'https://jestjs.io/docs/snapshot-testing'; | ||
@@ -81,3 +81,5 @@ export const SNAPSHOT_VERSION_WARNING = chalk.yellow( | ||
| chalk.red( | ||
| `${chalk.red.bold('Outdated guide link')}: The snapshot guide link is outdated.` + | ||
| `${chalk.red.bold( | ||
| 'Outdated guide link', | ||
| )}: The snapshot guide link is outdated.` + | ||
| 'Please update all snapshots while upgrading of Jest', | ||
@@ -84,0 +86,0 @@ ) + |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
30115
0.75%670
1.52%1
-50%