diff --git a/tap-snapshots/test/lib/publish.js.test.cjs b/tap-snapshots/test/lib/publish.js.test.cjs index 5f6c2ab63c51a..13e8f7d4b49fa 100644 --- a/tap-snapshots/test/lib/publish.js.test.cjs +++ b/tap-snapshots/test/lib/publish.js.test.cjs @@ -15,7 +15,7 @@ exports[`test/lib/publish.js TAP private workspaces colorless > should publish a Array [ Object { "_id": "@npmcli/b@1.0.0", - "gitHead": "1e8fd794b3375b083ab63224907213411099fa0e", + "gitHead": "{GITHEAD}", "name": "@npmcli/b", "readme": "ERROR: No README data found!", "version": "1.0.0", @@ -33,7 +33,7 @@ exports[`test/lib/publish.js TAP private workspaces with color > should publish Array [ Object { "_id": "@npmcli/b@1.0.0", - "gitHead": "1e8fd794b3375b083ab63224907213411099fa0e", + "gitHead": "{GITHEAD}", "name": "@npmcli/b", "readme": "ERROR: No README data found!", "version": "1.0.0", @@ -72,7 +72,7 @@ exports[`test/lib/publish.js TAP workspaces all workspaces > should publish all Array [ Object { "_id": "workspace-a@1.2.3-a", - "gitHead": "1e8fd794b3375b083ab63224907213411099fa0e", + "gitHead": "{GITHEAD}", "name": "workspace-a", "readme": "ERROR: No README data found!", "repository": Object { @@ -86,7 +86,7 @@ Array [ "bugs": Object { "url": "https://github.com/npm/workspace-b/issues", }, - "gitHead": "1e8fd794b3375b083ab63224907213411099fa0e", + "gitHead": "{GITHEAD}", "homepage": "https://github.com/npm/workspace-b#readme", "name": "workspace-b", "readme": "ERROR: No README data found!", @@ -98,7 +98,7 @@ Array [ }, Object { "_id": "workspace-n@1.2.3-n", - "gitHead": "1e8fd794b3375b083ab63224907213411099fa0e", + "gitHead": "{GITHEAD}", "name": "workspace-n", "readme": "ERROR: No README data found!", "version": "1.2.3-n", @@ -128,7 +128,7 @@ exports[`test/lib/publish.js TAP workspaces json > should publish all workspaces Array [ Object { "_id": "workspace-a@1.2.3-a", - "gitHead": "1e8fd794b3375b083ab63224907213411099fa0e", + "gitHead": "{GITHEAD}", "name": "workspace-a", "readme": "ERROR: No README data found!", "repository": Object { @@ -142,7 +142,7 @@ Array [ "bugs": Object { "url": "https://github.com/npm/workspace-b/issues", }, - "gitHead": "1e8fd794b3375b083ab63224907213411099fa0e", + "gitHead": "{GITHEAD}", "homepage": "https://github.com/npm/workspace-b#readme", "name": "workspace-b", "readme": "ERROR: No README data found!", @@ -154,7 +154,7 @@ Array [ }, Object { "_id": "workspace-n@1.2.3-n", - "gitHead": "1e8fd794b3375b083ab63224907213411099fa0e", + "gitHead": "{GITHEAD}", "name": "workspace-n", "readme": "ERROR: No README data found!", "version": "1.2.3-n", @@ -172,7 +172,7 @@ exports[`test/lib/publish.js TAP workspaces one workspace > should publish given Array [ Object { "_id": "workspace-a@1.2.3-a", - "gitHead": "1e8fd794b3375b083ab63224907213411099fa0e", + "gitHead": "{GITHEAD}", "name": "workspace-a", "readme": "ERROR: No README data found!", "repository": Object { diff --git a/test/lib/publish.js b/test/lib/publish.js index 4aa3e5592751e..6e0075835c269 100644 --- a/test/lib/publish.js +++ b/test/lib/publish.js @@ -9,6 +9,14 @@ const fs = require('fs') const log = require('npmlog') log.level = 'silent' +const cleanGithead = (result) => { + return result.map((r) => { + if (r.gitHead) + r.gitHead = '{GITHEAD}' + + return r + }) +} const {definitions} = require('../../lib/utils/config') const defaults = Object.entries(definitions).reduce((defaults, [key, def]) => { defaults[key] = def.default @@ -581,7 +589,7 @@ t.test('workspaces', (t) => { log.level = 'info' publish.execWorkspaces([], [], (err) => { t.notOk(err) - t.matchSnapshot(publishes, 'should publish all workspaces') + t.matchSnapshot(cleanGithead(publishes), 'should publish all workspaces') t.matchSnapshot(outputs, 'should output all publishes') t.end() }) @@ -591,7 +599,7 @@ t.test('workspaces', (t) => { log.level = 'info' publish.execWorkspaces([], ['workspace-a'], (err) => { t.notOk(err) - t.matchSnapshot(publishes, 'should publish given workspace') + t.matchSnapshot(cleanGithead(publishes), 'should publish given workspace') t.matchSnapshot(outputs, 'should output one publish') t.end() }) @@ -610,7 +618,7 @@ t.test('workspaces', (t) => { npm.config.set('json', true) publish.execWorkspaces([], [], (err) => { t.notOk(err) - t.matchSnapshot(publishes, 'should publish all workspaces') + t.matchSnapshot(cleanGithead(publishes), 'should publish all workspaces') t.matchSnapshot(outputs, 'should output all publishes as json') t.end() }) @@ -699,7 +707,7 @@ t.test('private workspaces', (t) => { npm.color = true publish.execWorkspaces([], [], (err) => { t.notOk(err) - t.matchSnapshot(publishes, 'should publish all non-private workspaces') + t.matchSnapshot(cleanGithead(publishes), 'should publish all non-private workspaces') t.matchSnapshot(outputs, 'should output all publishes') npm.color = false t.end() @@ -726,7 +734,7 @@ t.test('private workspaces', (t) => { publish.execWorkspaces([], [], (err) => { t.notOk(err) - t.matchSnapshot(publishes, 'should publish all non-private workspaces') + t.matchSnapshot(cleanGithead(publishes), 'should publish all non-private workspaces') t.matchSnapshot(outputs, 'should output all publishes') t.end() })