Skip to content

Commit f8cf453

Browse files
committed
chore: add failing test for v9.6.7 npm manifest snapshot
1 parent c2a4515 commit f8cf453

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed

tap-snapshots/test/lib/commands/publish.js.test.cjs

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,148 @@ exports[`test/lib/commands/publish.js TAP json > new package json 1`] = `
9999
}
100100
`
101101

102+
exports[`test/lib/commands/publish.js TAP manifest > manifest 1`] = `
103+
Object {
104+
"_id": "npm@{VERSION}",
105+
"author": Object {
106+
"name": "GitHub Inc.",
107+
},
108+
"bin": Object {
109+
"npm": "bin/npm-cli.js",
110+
"npx": "bin/npx-cli.js",
111+
},
112+
"bugs": Object {
113+
"url": "https://github.com/npm/cli/issues",
114+
},
115+
"description": "a package manager for JavaScript",
116+
"directories": Object {
117+
"bin": "./bin",
118+
"doc": "./doc",
119+
"lib": "./lib",
120+
"man": "./man",
121+
},
122+
"exports": Object {
123+
".": Array [
124+
Object {
125+
"default": "./index.js",
126+
},
127+
"./index.js",
128+
],
129+
"./package.json": "./package.json",
130+
},
131+
"files": Array [
132+
"bin/",
133+
"lib/",
134+
"index.js",
135+
"docs/content/",
136+
"docs/output/",
137+
"man/",
138+
],
139+
"homepage": "https://docs.npmjs.com/",
140+
"keywords": Array [
141+
"install",
142+
"modules",
143+
"package manager",
144+
"package.json",
145+
],
146+
"license": "Artistic-2.0",
147+
"main": "./index.js",
148+
"man": Array [
149+
"man/man1/npm-access.1",
150+
"man/man1/npm-adduser.1",
151+
"man/man1/npm-audit.1",
152+
"man/man1/npm-bugs.1",
153+
"man/man1/npm-cache.1",
154+
"man/man1/npm-ci.1",
155+
"man/man1/npm-completion.1",
156+
"man/man1/npm-config.1",
157+
"man/man1/npm-dedupe.1",
158+
"man/man1/npm-deprecate.1",
159+
"man/man1/npm-diff.1",
160+
"man/man1/npm-dist-tag.1",
161+
"man/man1/npm-docs.1",
162+
"man/man1/npm-doctor.1",
163+
"man/man1/npm-edit.1",
164+
"man/man1/npm-exec.1",
165+
"man/man1/npm-explain.1",
166+
"man/man1/npm-explore.1",
167+
"man/man1/npm-find-dupes.1",
168+
"man/man1/npm-fund.1",
169+
"man/man1/npm-help-search.1",
170+
"man/man1/npm-help.1",
171+
"man/man1/npm-hook.1",
172+
"man/man1/npm-init.1",
173+
"man/man1/npm-install-ci-test.1",
174+
"man/man1/npm-install-test.1",
175+
"man/man1/npm-install.1",
176+
"man/man1/npm-link.1",
177+
"man/man1/npm-login.1",
178+
"man/man1/npm-logout.1",
179+
"man/man1/npm-ls.1",
180+
"man/man1/npm-org.1",
181+
"man/man1/npm-outdated.1",
182+
"man/man1/npm-owner.1",
183+
"man/man1/npm-pack.1",
184+
"man/man1/npm-ping.1",
185+
"man/man1/npm-pkg.1",
186+
"man/man1/npm-prefix.1",
187+
"man/man1/npm-profile.1",
188+
"man/man1/npm-prune.1",
189+
"man/man1/npm-publish.1",
190+
"man/man1/npm-query.1",
191+
"man/man1/npm-rebuild.1",
192+
"man/man1/npm-repo.1",
193+
"man/man1/npm-restart.1",
194+
"man/man1/npm-root.1",
195+
"man/man1/npm-run-script.1",
196+
"man/man1/npm-search.1",
197+
"man/man1/npm-shrinkwrap.1",
198+
"man/man1/npm-star.1",
199+
"man/man1/npm-stars.1",
200+
"man/man1/npm-start.1",
201+
"man/man1/npm-stop.1",
202+
"man/man1/npm-team.1",
203+
"man/man1/npm-test.1",
204+
"man/man1/npm-token.1",
205+
"man/man1/npm-uninstall.1",
206+
"man/man1/npm-unpublish.1",
207+
"man/man1/npm-unstar.1",
208+
"man/man1/npm-update.1",
209+
"man/man1/npm-version.1",
210+
"man/man1/npm-view.1",
211+
"man/man1/npm-whoami.1",
212+
"man/man1/npm.1",
213+
"man/man1/npx.1",
214+
"man/man5/folders.5",
215+
"man/man5/install.5",
216+
"man/man5/npm-global.5",
217+
"man/man5/npm-json.5",
218+
"man/man5/npm-shrinkwrap-json.5",
219+
"man/man5/npmrc.5",
220+
"man/man5/package-json.5",
221+
"man/man5/package-lock-json.5",
222+
"man/man7/config.7",
223+
"man/man7/dependency-selectors.7",
224+
"man/man7/developers.7",
225+
"man/man7/logging.7",
226+
"man/man7/orgs.7",
227+
"man/man7/package-spec.7",
228+
"man/man7/registry.7",
229+
"man/man7/removal.7",
230+
"man/man7/scope.7",
231+
"man/man7/scripts.7",
232+
"man/man7/workspaces.7",
233+
],
234+
"name": "npm",
235+
"readmeFilename": "README.md",
236+
"repository": Object {
237+
"type": "git",
238+
"url": "git+https://github.com/npm/cli.git",
239+
},
240+
"version": "{VERSION}",
241+
}
242+
`
243+
102244
exports[`test/lib/commands/publish.js TAP no auth dry-run > must match snapshot 1`] = `
103245
104246
`

test/lib/commands/publish.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,3 +719,54 @@ t.test('public access', async t => {
719719
t.matchSnapshot(joinedOutput(), 'new package version')
720720
t.matchSnapshot(logs.notice)
721721
})
722+
723+
t.test('manifest', async t => {
724+
// https://github.com/npm/cli/pull/6470#issuecomment-1571234863
725+
726+
// snapshot test that was generated against v9.6.7 originally to ensure our
727+
// own manifest does not change unexpectedly when publishing. this test
728+
// asserts a bunch of keys are there that will change often and then snapshots
729+
// the rest of the manifest.
730+
731+
const root = path.resolve(__dirname, '../../..')
732+
const npmPkg = require(path.join(root, 'package.json'))
733+
734+
t.cleanSnapshot = (s) => s.replace(new RegExp(npmPkg.version, 'g'), '{VERSION}')
735+
736+
let manifest = null
737+
const { npm } = await loadMockNpm(t, {
738+
config: {
739+
...auth,
740+
},
741+
chdir: () => root,
742+
mocks: {
743+
libnpmpublish: {
744+
publish: (m) => manifest = m,
745+
},
746+
},
747+
})
748+
await npm.exec('publish', [])
749+
750+
const okKeys = [
751+
'contributors',
752+
'bundleDependencies',
753+
'dependencies',
754+
'devDependencies',
755+
'templateOSS',
756+
'scripts',
757+
'tap',
758+
'readme',
759+
'gitHead',
760+
'engines',
761+
'workspaces',
762+
]
763+
764+
for (const k of okKeys) {
765+
t.ok(manifest[k], k)
766+
delete manifest[k]
767+
}
768+
769+
manifest.man.sort()
770+
771+
t.matchSnapshot(manifest, 'manifest')
772+
})

0 commit comments

Comments
 (0)