Skip to content

Commit f963180

Browse files
committed
chore: convert all test to mockNpm
This also uses more consistent snapshot cleaning where possible. Note that this is an iterative step for our tests and does not implement `MockRegistry` for them, so many of them still mock important functionality that should be tested. This refactor to `mockNpm` should make it easier to adopt `MockRegistry` as we see fit.
1 parent b54ab92 commit f963180

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4421
-5832
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ audited 1 package in xxx
123123
124124
1 package has an invalid registry signature:
125125
126-
@npmcli/[email protected] (https://verdaccio-clone.org)
126+
@npmcli/[email protected] (https://verdaccio-clone.org/)
127127
128128
Someone might have tampered with this package since it was published on the registry!
129129
@@ -134,7 +134,7 @@ audited 1 package in xxx
134134
135135
1 package has a missing registry signature but the registry is providing signing keys:
136136
137-
@npmcli/[email protected] (https://verdaccio-clone.org)
137+
@npmcli/[email protected] (https://verdaccio-clone.org/)
138138
`
139139

140140
exports[`test/lib/commands/audit.js TAP audit signatures third-party registry with keys and signatures > must match snapshot 1`] = `

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ exports[`test/lib/commands/config.js TAP config list with publishConfig > output
354354
; "cli" config from command line options
355355
356356
cache = "{NPMDIR}/test/lib/commands/tap-testdir-config-config-list-with-publishConfig-sandbox/cache"
357-
location = "project"
358357
prefix = "{LOCALPREFIX}"
359358
userconfig = "{HOME}/.npmrc"
360359

tap-snapshots/test/lib/commands/dist-tag.js.test.cjs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ exports[`test/lib/commands/dist-tag.js TAP add new tag > should return success m
1010
`
1111

1212
exports[`test/lib/commands/dist-tag.js TAP add using valid semver range as name > should return success msg 1`] = `
13-
dist-tag add 1.0.0 to @scoped/[email protected]
14-
13+
dist-tag add 1.0.0 to @scoped/[email protected]
1514
`
1615

1716
exports[`test/lib/commands/dist-tag.js TAP ls in current package > should list available tags for current package 1`] = `
@@ -21,8 +20,7 @@ latest: 1.0.0
2120
`
2221

2322
exports[`test/lib/commands/dist-tag.js TAP ls on missing package > should log no dist-tag found msg 1`] = `
24-
dist-tag ls Couldn't get dist-tag data for foo@*
25-
23+
dist-tag ls Couldn't get dist-tag data for foo@*
2624
`
2725

2826
exports[`test/lib/commands/dist-tag.js TAP ls on named package > should list tags for the specified package 1`] = `
@@ -44,24 +42,21 @@ latest: 2.0.0
4442
`
4543

4644
exports[`test/lib/commands/dist-tag.js TAP remove existing tag > should log remove info 1`] = `
47-
dist-tag del c from @scoped/another
48-
45+
dist-tag del c from @scoped/another
4946
`
5047

5148
exports[`test/lib/commands/dist-tag.js TAP remove existing tag > should return success msg 1`] = `
5249
-c: @scoped/[email protected]
5350
`
5451

5552
exports[`test/lib/commands/dist-tag.js TAP remove non-existing tag > should log error msg 1`] = `
56-
dist-tag del nonexistent from @scoped/another
57-
dist-tag del nonexistent is not a dist-tag on @scoped/another
58-
53+
dist-tag del nonexistent from @scoped/another
54+
dist-tag del nonexistent is not a dist-tag on @scoped/another
5955
`
6056

6157
exports[`test/lib/commands/dist-tag.js TAP set existing version > should log warn msg 1`] = `
62-
dist-tag add b to @scoped/[email protected]
63-
dist-tag add b is already set to version 0.6.0
64-
58+
dist-tag add b to @scoped/[email protected]
59+
dist-tag add b is already set to version 0.6.0
6560
`
6661

6762
exports[`test/lib/commands/dist-tag.js TAP workspaces no args > printed the expected output 1`] = `

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

Lines changed: 48 additions & 48 deletions
Large diffs are not rendered by default.

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,50 @@
66
*/
77
'use strict'
88
exports[`test/lib/commands/link.js TAP hash character in working directory path > should create a global link to current pkg, even within path with hash 1`] = `
9-
{CWD}/test/lib/commands/tap-testdir-link-hash-character-in-working-directory-path/global-prefix/lib/node_modules/test-pkg-link -> {CWD}/test/lib/commands/tap-testdir-link-hash-character-in-working-directory-path/i_like_#_in_my_paths/test-pkg-link
9+
{CWD}/global/node_modules/test-pkg-link -> {CWD}/other/i_like_#_in_my_paths/test-pkg-link
1010
1111
`
1212

1313
exports[`test/lib/commands/link.js TAP link global linked pkg to local nm when using args > should create a local symlink to global pkg 1`] = `
14-
{CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-nm-when-using-args/my-project/node_modules/@myscope/bar -> {CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-nm-when-using-args/global-prefix/lib/node_modules/@myscope/bar
15-
{CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-nm-when-using-args/my-project/node_modules/@myscope/linked -> {CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-nm-when-using-args/scoped-linked
16-
{CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-nm-when-using-args/my-project/node_modules/a -> {CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-nm-when-using-args/global-prefix/lib/node_modules/a
17-
{CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-nm-when-using-args/my-project/node_modules/link-me-too -> {CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-nm-when-using-args/link-me-too
18-
{CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-nm-when-using-args/my-project/node_modules/test-pkg-link -> {CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-nm-when-using-args/test-pkg-link
14+
{CWD}/prefix/node_modules/@myscope/bar -> {CWD}/global/node_modules/@myscope/bar
15+
{CWD}/prefix/node_modules/@myscope/linked -> {CWD}/other/scoped-linked
16+
{CWD}/prefix/node_modules/a -> {CWD}/global/node_modules/a
17+
{CWD}/prefix/node_modules/link-me-too -> {CWD}/other/link-me-too
18+
{CWD}/prefix/node_modules/test-pkg-link -> {CWD}/other/test-pkg-link
1919
2020
`
2121

2222
exports[`test/lib/commands/link.js TAP link global linked pkg to local workspace using args > should create a local symlink to global pkg 1`] = `
23-
{CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/my-project/node_modules/@myscope/bar -> {CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/global-prefix/lib/node_modules/@myscope/bar
24-
{CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/my-project/node_modules/@myscope/linked -> {CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/scoped-linked
25-
{CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/my-project/node_modules/a -> {CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/global-prefix/lib/node_modules/a
26-
{CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/my-project/node_modules/link-me-too -> {CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/link-me-too
27-
{CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/my-project/node_modules/test-pkg-link -> {CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/test-pkg-link
28-
{CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/my-project/node_modules/x -> {CWD}/test/lib/commands/tap-testdir-link-link-global-linked-pkg-to-local-workspace-using-args/my-project/packages/x
23+
{CWD}/prefix/node_modules/@myscope/bar -> {CWD}/global/node_modules/@myscope/bar
24+
{CWD}/prefix/node_modules/@myscope/linked -> {CWD}/other/scoped-linked
25+
{CWD}/prefix/node_modules/a -> {CWD}/global/node_modules/a
26+
{CWD}/prefix/node_modules/link-me-too -> {CWD}/other/link-me-too
27+
{CWD}/prefix/node_modules/test-pkg-link -> {CWD}/other/test-pkg-link
28+
{CWD}/prefix/node_modules/x -> {CWD}/prefix/packages/x
2929
3030
`
3131

3232
exports[`test/lib/commands/link.js TAP link pkg already in global space > should create a local symlink to global pkg 1`] = `
33-
{CWD}/test/lib/commands/tap-testdir-link-link-pkg-already-in-global-space/my-project/node_modules/@myscope/linked -> {CWD}/test/lib/commands/tap-testdir-link-link-pkg-already-in-global-space/scoped-linked
33+
{CWD}/prefix/node_modules/@myscope/linked -> {CWD}/other/scoped-linked
3434
3535
`
3636

3737
exports[`test/lib/commands/link.js TAP link pkg already in global space when prefix is a symlink > should create a local symlink to global pkg 1`] = `
38-
{CWD}/test/lib/commands/tap-testdir-link-link-pkg-already-in-global-space-when-prefix-is-a-symlink/my-project/node_modules/@myscope/linked -> {CWD}/test/lib/commands/tap-testdir-link-link-pkg-already-in-global-space-when-prefix-is-a-symlink/scoped-linked
38+
{CWD}/prefix/node_modules/@myscope/linked -> {CWD}/other/scoped-linked
3939
4040
`
4141

4242
exports[`test/lib/commands/link.js TAP link to globalDir when in current working dir of pkg and no args > should create a global link to current pkg 1`] = `
43-
{CWD}/test/lib/commands/tap-testdir-link-link-to-globalDir-when-in-current-working-dir-of-pkg-and-no-args/global-prefix/lib/node_modules/test-pkg-link -> {CWD}/test/lib/commands/tap-testdir-link-link-to-globalDir-when-in-current-working-dir-of-pkg-and-no-args/test-pkg-link
43+
{CWD}/global/node_modules/test-pkg-link -> {CWD}/prefix
4444
4545
`
4646

4747
exports[`test/lib/commands/link.js TAP link ws to globalDir when workspace specified and no args > should create a global link to current pkg 1`] = `
48-
{CWD}/test/lib/commands/tap-testdir-link-link-ws-to-globalDir-when-workspace-specified-and-no-args/global-prefix/lib/node_modules/a -> {CWD}/test/lib/commands/tap-testdir-link-link-ws-to-globalDir-when-workspace-specified-and-no-args/test-pkg-link/packages/a
48+
{CWD}/global/node_modules/a -> {CWD}/prefix/packages/a
4949
5050
`
5151

5252
exports[`test/lib/commands/link.js TAP test linked installed as symlinks > linked package should not be installed 1`] = `
53-
{CWD}/test/lib/commands/tap-testdir-link-test-linked-installed-as-symlinks/prefix/node_modules/mylink -> {CWD}/test/lib/commands/tap-testdir-link-test-linked-installed-as-symlinks/other/mylink
53+
{CWD}/prefix/node_modules/mylink -> {CWD}/other/mylink
5454
5555
`

0 commit comments

Comments
 (0)