Skip to content

Commit 87dfab9

Browse files
committed
Group color enabled tests
1 parent c26eb29 commit 87dfab9

2 files changed

Lines changed: 76 additions & 74 deletions

File tree

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ verified registry signatures, audited 1 package in 0s
148148
149149
`
150150

151-
exports[`test/lib/commands/audit.js TAP audit signatures with color and both valid and missing signatures > must match snapshot 1`] = `
151+
exports[`test/lib/commands/audit.js TAP audit signatures with color output enabled with both valid and missing signatures > must match snapshot 1`] = `
152152
audited 2 packages in xxx
153153
154154
1 packages have verified registry signatures
@@ -157,7 +157,18 @@ audited 2 packages in xxx
157157
run \`npm audit signatures --missing\` for details
158158
`
159159

160-
exports[`test/lib/commands/audit.js TAP audit signatures with color and multiple invalid signatures > must match snapshot 1`] = `
160+
exports[`test/lib/commands/audit.js TAP audit signatures with color output enabled with invalid signatures > must match snapshot 1`] = `
161+
audited 1 package in 0s
162+
163+
1 package has an invalid registry signature:
164+
165+
kms-demo@1.0.0
166+
167+
Someone might have tampered with the package since it was published on the registry (monster-in-the-middle attack)!
168+
169+
`
170+
171+
exports[`test/lib/commands/audit.js TAP audit signatures with color output enabled with multiple invalid signatures > must match snapshot 1`] = `
161172
audited 2 packages in xxx
162173
163174
2 packages have invalid registry signatures:
@@ -169,24 +180,13 @@ Someone might have tampered with the packages since it was published on the regi
169180
170181
`
171182

172-
exports[`test/lib/commands/audit.js TAP audit signatures with color and multiple missing signatures > must match snapshot 1`] = `
183+
exports[`test/lib/commands/audit.js TAP audit signatures with color output enabled with multiple missing signatures > must match snapshot 1`] = `
173184
audited 2 packages in xxx
174185
175186
2 packages have missing registry signatures but the registry is providing signing keys
176187
run \`npm audit signatures --missing\` for details
177188
`
178189

179-
exports[`test/lib/commands/audit.js TAP audit signatures with colour option and invalid signatures > must match snapshot 1`] = `
180-
audited 1 package in 0s
181-
182-
1 package has an invalid registry signature:
183-
184-
kms-demo@1.0.0
185-
186-
Someone might have tampered with the package since it was published on the registry (monster-in-the-middle attack)!
187-
188-
`
189-
190190
exports[`test/lib/commands/audit.js TAP audit signatures with invalid signatures > must match snapshot 1`] = `
191191
audited 1 package in 0s
192192

test/lib/commands/audit.js

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -871,24 +871,6 @@ t.test('audit signatures', async t => {
871871
t.matchSnapshot(joinedOutput())
872872
})
873873

874-
t.test('with colour option and invalid signatures', async t => {
875-
npm.prefix = validInstall()
876-
npm.color = true
877-
await manifestWithInvalidSigs()
878-
validKeys()
879-
880-
await audit.exec(['signatures'])
881-
882-
t.equal(process.exitCode, 1, 'should exit with error')
883-
process.exitCode = 0
884-
t.match(
885-
joinedOutput(),
886-
/* eslint-disable-next-line no-control-regex */
887-
/\u001b\[1m\u001b\[31minvalid\u001b\[39m\u001b\[22m registry signature/
888-
)
889-
t.matchSnapshot(joinedOutput())
890-
})
891-
892874
t.test('with invalid signatures', async t => {
893875
npm.prefix = validInstall()
894876
await manifestWithInvalidSigs()
@@ -919,20 +901,6 @@ t.test('audit signatures', async t => {
919901
t.matchSnapshot(joinedOutput())
920902
})
921903

922-
t.test('with color and both valid and missing signatures', async t => {
923-
npm.prefix = installWithMultipleDeps()
924-
npm.color = true
925-
await manifestWithValidSigs()
926-
await manifestWithoutSigs('async', '1.1.1')
927-
validKeys()
928-
929-
await audit.exec(['signatures'])
930-
931-
t.equal(process.exitCode, 1, 'should exit with error')
932-
process.exitCode = 0
933-
t.matchSnapshot(joinedOutput())
934-
})
935-
936904
t.test('with both invalid and missing signatures', async t => {
937905
npm.prefix = installWithMultipleDeps()
938906
await manifestWithInvalidSigs()
@@ -962,20 +930,6 @@ t.test('audit signatures', async t => {
962930
t.matchSnapshot(joinedOutput())
963931
})
964932

965-
t.test('with color and multiple invalid signatures', async t => {
966-
npm.prefix = installWithMultipleDeps()
967-
npm.color = true
968-
await manifestWithInvalidSigs('kms-demo', '1.0.0')
969-
await manifestWithInvalidSigs('async', '1.1.1')
970-
validKeys()
971-
972-
await audit.exec(['signatures'])
973-
974-
t.equal(process.exitCode, 1, 'should exit with error')
975-
process.exitCode = 0
976-
t.matchSnapshot(joinedOutput())
977-
})
978-
979933
t.test('with multiple missing signatures', async t => {
980934
npm.prefix = installWithMultipleDeps()
981935
await manifestWithoutSigs('kms-demo', '1.0.0')
@@ -989,20 +943,6 @@ t.test('audit signatures', async t => {
989943
t.matchSnapshot(joinedOutput())
990944
})
991945

992-
t.test('with color and multiple missing signatures', async t => {
993-
npm.prefix = installWithMultipleDeps()
994-
npm.color = true
995-
await manifestWithoutSigs('kms-demo', '1.0.0')
996-
await manifestWithoutSigs('async', '1.1.1')
997-
validKeys()
998-
999-
await audit.exec(['signatures'])
1000-
1001-
t.equal(process.exitCode, 1, 'should exit with error')
1002-
process.exitCode = 0
1003-
t.matchSnapshot(joinedOutput())
1004-
})
1005-
1006946
t.test('with signatures but no public keys', async t => {
1007947
npm.prefix = validInstall()
1008948
await manifestWithValidSigs()
@@ -1454,6 +1394,68 @@ t.test('audit signatures', async t => {
14541394
)
14551395
})
14561396

1397+
t.test('with color output enabled', async t => {
1398+
t.test('with invalid signatures', async t => {
1399+
npm.prefix = validInstall()
1400+
npm.color = true
1401+
await manifestWithInvalidSigs()
1402+
validKeys()
1403+
1404+
await audit.exec(['signatures'])
1405+
1406+
t.equal(process.exitCode, 1, 'should exit with error')
1407+
process.exitCode = 0
1408+
t.match(
1409+
joinedOutput(),
1410+
/* eslint-disable-next-line no-control-regex */
1411+
/\u001b\[1m\u001b\[31minvalid\u001b\[39m\u001b\[22m registry signature/
1412+
)
1413+
t.matchSnapshot(joinedOutput())
1414+
})
1415+
1416+
t.test('with both valid and missing signatures', async t => {
1417+
npm.prefix = installWithMultipleDeps()
1418+
npm.color = true
1419+
await manifestWithValidSigs()
1420+
await manifestWithoutSigs('async', '1.1.1')
1421+
validKeys()
1422+
1423+
await audit.exec(['signatures'])
1424+
1425+
t.equal(process.exitCode, 1, 'should exit with error')
1426+
process.exitCode = 0
1427+
t.matchSnapshot(joinedOutput())
1428+
})
1429+
1430+
t.test('with multiple invalid signatures', async t => {
1431+
npm.prefix = installWithMultipleDeps()
1432+
npm.color = true
1433+
await manifestWithInvalidSigs('kms-demo', '1.0.0')
1434+
await manifestWithInvalidSigs('async', '1.1.1')
1435+
validKeys()
1436+
1437+
await audit.exec(['signatures'])
1438+
1439+
t.equal(process.exitCode, 1, 'should exit with error')
1440+
process.exitCode = 0
1441+
t.matchSnapshot(joinedOutput())
1442+
})
1443+
1444+
t.test('with multiple missing signatures', async t => {
1445+
npm.prefix = installWithMultipleDeps()
1446+
npm.color = true
1447+
await manifestWithoutSigs('kms-demo', '1.0.0')
1448+
await manifestWithoutSigs('async', '1.1.1')
1449+
validKeys()
1450+
1451+
await audit.exec(['signatures'])
1452+
1453+
t.equal(process.exitCode, 1, 'should exit with error')
1454+
process.exitCode = 0
1455+
t.matchSnapshot(joinedOutput())
1456+
})
1457+
})
1458+
14571459
t.test('workspaces', async t => {
14581460
t.test('verifies registry deps and ignores local workspace deps', async t => {
14591461
npm.prefix = workspaceInstall()

0 commit comments

Comments
 (0)