Skip to content

Commit 6cc4a93

Browse files
authored
chore: add full flatOptions snapshot test (#6508)
1 parent 5a1754c commit 6cc4a93

File tree

2 files changed

+148
-0
lines changed

2 files changed

+148
-0
lines changed

tap-snapshots/test/lib/docs.js.test.cjs

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,6 +2027,128 @@ Array [
20272027
]
20282028
`
20292029

2030+
exports[`test/lib/docs.js TAP flat options > full flat options object 1`] = `
2031+
Object {
2032+
"_auth": null,
2033+
"access": null,
2034+
"all": false,
2035+
"allowSameVersion": false,
2036+
"audit": true,
2037+
"auditLevel": null,
2038+
"authType": "web",
2039+
"before": null,
2040+
"binLinks": true,
2041+
"browser": null,
2042+
"ca": null,
2043+
"cache": "{CWD}/cache/_cacache",
2044+
"call": "",
2045+
"cert": null,
2046+
"cidr": null,
2047+
"ciName": "{ci}",
2048+
"color": false,
2049+
"commitHooks": true,
2050+
"defaultTag": "latest",
2051+
"depth": null,
2052+
"diff": Array [],
2053+
"diffDstPrefix": "b/",
2054+
"diffIgnoreAllSpace": false,
2055+
"diffNameOnly": false,
2056+
"diffNoPrefix": false,
2057+
"diffSrcPrefix": "a/",
2058+
"diffText": false,
2059+
"diffUnified": 3,
2060+
"dryRun": false,
2061+
"editor": "{EDITOR}",
2062+
"engineStrict": false,
2063+
"force": false,
2064+
"foregroundScripts": false,
2065+
"formatPackageLock": true,
2066+
"fund": true,
2067+
"git": "git",
2068+
"gitTagVersion": true,
2069+
"global": false,
2070+
"globalconfig": "{CWD}/global/etc/npmrc",
2071+
"hashAlgorithm": "sha1",
2072+
"heading": "npm",
2073+
"httpsProxy": null,
2074+
"ifPresent": false,
2075+
"ignoreScripts": false,
2076+
"includeStaged": false,
2077+
"includeWorkspaceRoot": false,
2078+
"installLinks": false,
2079+
"installStrategy": "hoisted",
2080+
"json": false,
2081+
"key": null,
2082+
"legacyPeerDeps": false,
2083+
"localAddress": null,
2084+
"location": "user",
2085+
"lockfileVersion": null,
2086+
"logColor": false,
2087+
"maxSockets": 15,
2088+
"message": "%s",
2089+
"nodeBin": "{NODE}",
2090+
"nodeVersion": "2.2.2",
2091+
"noProxy": "",
2092+
"npmBin": "{CWD}/{TESTDIR}/docs.js",
2093+
"npmCommand": "version",
2094+
"npmVersion": "1.1.1",
2095+
"npxCache": "{CWD}/cache/_npx",
2096+
"offline": false,
2097+
"omit": Array [],
2098+
"omitLockfileRegistryResolved": false,
2099+
"otp": null,
2100+
"package": Array [],
2101+
"packageLock": true,
2102+
"packageLockOnly": false,
2103+
"packDestination": ".",
2104+
"parseable": false,
2105+
"preferDedupe": false,
2106+
"preferOffline": false,
2107+
"preferOnline": false,
2108+
"preid": "",
2109+
"progress": false,
2110+
"projectScope": "",
2111+
"provenance": false,
2112+
"proxy": null,
2113+
"readOnly": false,
2114+
"rebuildBundle": true,
2115+
"registry": "https://registry.npmjs.org/",
2116+
"replaceRegistryHost": "npmjs",
2117+
"retry": Object {
2118+
"factor": 10,
2119+
"maxTimeout": 60000,
2120+
"minTimeout": 10000,
2121+
"retries": 0,
2122+
},
2123+
"save": true,
2124+
"saveBundle": false,
2125+
"savePrefix": "^",
2126+
"scope": "",
2127+
"scriptShell": undefined,
2128+
"search": Object {
2129+
"description": true,
2130+
"exclude": "",
2131+
"limit": 20,
2132+
"opts": Null Object {},
2133+
"staleness": 900,
2134+
},
2135+
"shell": "{SHELL}",
2136+
"signGitCommit": false,
2137+
"signGitTag": false,
2138+
"silent": false,
2139+
"strictPeerDeps": false,
2140+
"strictSSL": true,
2141+
"tagVersionPrefix": "v",
2142+
"timeout": 300000,
2143+
"tufCache": "{CWD}/cache/_tuf",
2144+
"umask": 0,
2145+
"unicode": false,
2146+
"userAgent": "npm/1.1.1 node/2.2.2 {PLATFORM} {ARCH} workspaces/false ci/{ci}",
2147+
"workspacesEnabled": true,
2148+
"workspacesUpdate": true,
2149+
}
2150+
`
2151+
20302152
exports[`test/lib/docs.js TAP shorthands > docs 1`] = `
20312153
* \`-a\`: \`--all\`
20322154
* \`--enjoy-by\`: \`--before\`

test/lib/docs.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const { load: loadMockNpm } = require('../fixtures/mock-npm.js')
88
const { definitions } = require('../../lib/utils/config/index.js')
99
const cmdList = require('../../lib/utils/cmd-list.js')
1010
const pkg = require('../../package.json')
11+
const { cleanCwd } = require('../fixtures/clean-snapshot.js')
1112

1213
t.test('command list', async t => {
1314
for (const [key, value] of Object.entries(cmdList)) {
@@ -29,6 +30,31 @@ t.test('config', async t => {
2930
t.matchSnapshot(docs.config(docs.TAGS.CONFIG, {}), 'all definitions')
3031
})
3132

33+
t.test('flat options', async t => {
34+
t.cleanSnapshot = (s) => cleanCwd(s)
35+
.split(cleanCwd(process.execPath)).join('{NODE}')
36+
37+
const { npm } = await loadMockNpm(t, {
38+
command: 'version',
39+
exec: true,
40+
globals: {
41+
'process.env': {
42+
EDITOR: '{EDITOR}',
43+
SHELL: '{SHELL}',
44+
},
45+
'process.version': '2.2.2',
46+
'process.platform': '{PLATFORM}',
47+
'process.arch': '{ARCH}',
48+
},
49+
mocks: {
50+
'ci-info': { name: '{CI}' },
51+
'{ROOT}/package.json': { version: '1.1.1' },
52+
},
53+
})
54+
55+
t.matchSnapshot(npm.flatOptions, 'full flat options object')
56+
})
57+
3258
t.test('basic usage', async t => {
3359
// snapshot basic usage without commands since all the command snapshots
3460
// are generated in the following test

0 commit comments

Comments
 (0)