From 60c4e42bf2151016f634b14bb6fff913fd3e2b64 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:06:42 +0900 Subject: [PATCH] test: remove snapshots to avoid lock-in to Jest --- .../aggregateReport.test.js.snap | 65 ------------------- lib/__tests__/aggregateReport.test.js | 63 +++++++++++++++++- 2 files changed, 62 insertions(+), 66 deletions(-) delete mode 100644 lib/__tests__/__snapshots__/aggregateReport.test.js.snap diff --git a/lib/__tests__/__snapshots__/aggregateReport.test.js.snap b/lib/__tests__/__snapshots__/aggregateReport.test.js.snap deleted file mode 100644 index f5fa977b..00000000 --- a/lib/__tests__/__snapshots__/aggregateReport.test.js.snap +++ /dev/null @@ -1,65 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`aggregateReport() 1`] = ` -{ - "added": [ - { - "location": null, - "name": "arrify", - "version": "2.0.1", - }, - ], - "packageCount": 4, - "packageUrls": { - "arrify": { - "name": "arrify", - "type": "github", - "url": "https://github.com/sindresorhus/arrify", - }, - "css-select": { - "name": "css-select", - "type": "github", - "url": "https://github.com/fb55/css-select", - }, - "xmldom": { - "name": "xmldom", - "type": "github", - "url": "https://github.com/xmldom/xmldom", - }, - "y18n": { - "name": "y18n", - "type": "github", - "url": "https://github.com/yargs/y18n", - }, - }, - "removed": [ - { - "location": "svgo/node_modules/css-select", - "name": "css-select", - "severity": null, - "title": null, - "url": null, - "version": "3.1.2", - }, - { - "location": null, - "name": "xmldom", - "severity": "Low", - "title": "Misinterpretation of malicious XML input", - "url": "https://npmjs.com/advisories/1650", - "version": "0.5.0", - }, - ], - "updated": [ - { - "location": null, - "name": "y18n", - "previousVersion": "4.0.0", - "severity": "High", - "title": "Prototype Pollution", - "url": "https://npmjs.com/advisories/1654", - "version": "4.0.1", - }, - ], -} -`; diff --git a/lib/__tests__/aggregateReport.test.js b/lib/__tests__/aggregateReport.test.js index ce7ecf39..c895ee31 100644 --- a/lib/__tests__/aggregateReport.test.js +++ b/lib/__tests__/aggregateReport.test.js @@ -2,6 +2,7 @@ import { test, expect } from "@jest/globals"; import aggregateReport from "../aggregateReport.js"; +// eslint-disable-next-line max-lines-per-function test("aggregateReport()", async () => { const audit = new Map(); audit.set("y18n", { @@ -29,5 +30,65 @@ test("aggregateReport()", async () => { after.set("rimraf:rimraf", "3.0.2"); const result = await aggregateReport(audit, before, after); - expect(result).toMatchSnapshot(); + expect(result).toEqual({ + added: [ + { + location: null, + name: "arrify", + version: "2.0.1", + }, + ], + packageCount: 4, + packageUrls: { + arrify: { + name: "arrify", + type: "github", + url: "https://github.com/sindresorhus/arrify", + }, + "css-select": { + name: "css-select", + type: "github", + url: "https://github.com/fb55/css-select", + }, + xmldom: { + name: "xmldom", + type: "github", + url: "https://github.com/xmldom/xmldom", + }, + y18n: { + name: "y18n", + type: "github", + url: "https://github.com/yargs/y18n", + }, + }, + removed: [ + { + location: "svgo/node_modules/css-select", + name: "css-select", + severity: null, + title: null, + url: null, + version: "3.1.2", + }, + { + location: null, + name: "xmldom", + severity: "Low", + title: "Misinterpretation of malicious XML input", + url: "https://npmjs.com/advisories/1650", + version: "0.5.0", + }, + ], + updated: [ + { + location: null, + name: "y18n", + previousVersion: "4.0.0", + severity: "High", + title: "Prototype Pollution", + url: "https://npmjs.com/advisories/1654", + version: "4.0.1", + }, + ], + }); });