Skip to content

Commit

Permalink
mock process in snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
reggi committed Sep 6, 2024
1 parent 736e6fc commit 219bb83
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 127 deletions.
30 changes: 15 additions & 15 deletions tap-snapshots/test/lib/commands/install.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/lib/commands/install.js TAP should utilize devEngines 2x error case > must match snapshot 1`] = `
exports[`test/lib/commands/install.js TAP devEngines should utilize devEngines 2x error case > must match snapshot 1`] = `
silly config load:file:{CWD}/npmrc
silly config load:file:{CWD}/prefix/.npmrc
silly config load:file:{CWD}/home/.npmrc
Expand All @@ -26,12 +26,12 @@ error EBADDEVENGINES The developer of this package has specified the following t
error EBADDEVENGINES Invalid engine "runtime"
error EBADDEVENGINES Invalid name "nondescript" does not match "node" for "runtime"
error EBADDEVENGINES {
error EBADDEVENGINES current: { name: 'node', version: 'v22.5.1' },
error EBADDEVENGINES current: { name: 'node', version: 'v1337.0.0' },
error EBADDEVENGINES required: { name: 'nondescript', onFail: 'error' }
error EBADDEVENGINES }
`

exports[`test/lib/commands/install.js TAP should utilize devEngines 2x warning case > must match snapshot 1`] = `
exports[`test/lib/commands/install.js TAP devEngines should utilize devEngines 2x warning case > must match snapshot 1`] = `
silly config load:file:{CWD}/npmrc
silly config load:file:{CWD}/prefix/.npmrc
silly config load:file:{CWD}/home/.npmrc
Expand All @@ -45,13 +45,13 @@ warn EBADDEVENGINES The developer of this package has specified the following th
warn EBADDEVENGINES Invalid engine "runtime"
warn EBADDEVENGINES Invalid name "nondescript" does not match "node" for "runtime"
warn EBADDEVENGINES {
warn EBADDEVENGINES current: { name: 'node', version: 'v22.5.1' },
warn EBADDEVENGINES current: { name: 'node', version: 'v1337.0.0' },
warn EBADDEVENGINES required: { name: 'nondescript', onFail: 'warn' }
warn EBADDEVENGINES }
warn EBADDEVENGINES Invalid engine "cpu"
warn EBADDEVENGINES Invalid name "risv" does not match "arm64" for "cpu"
warn EBADDEVENGINES Invalid name "risv" does not match "x86" for "cpu"
warn EBADDEVENGINES {
warn EBADDEVENGINES current: { name: 'arm64' },
warn EBADDEVENGINES current: { name: 'x86' },
warn EBADDEVENGINES required: { name: 'risv', onFail: 'warn' }
warn EBADDEVENGINES }
silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
Expand All @@ -63,7 +63,7 @@ up to date, audited 1 package in {TIME}
found 0 vulnerabilities
`

exports[`test/lib/commands/install.js TAP should utilize devEngines failure and warning case > must match snapshot 1`] = `
exports[`test/lib/commands/install.js TAP devEngines should utilize devEngines failure and warning case > must match snapshot 1`] = `
silly config load:file:{CWD}/npmrc
silly config load:file:{CWD}/prefix/.npmrc
silly config load:file:{CWD}/home/.npmrc
Expand All @@ -75,9 +75,9 @@ verbose logfile {CWD}/cache/_logs/{DATE}-debug-0.log
silly logfile done cleaning log files
warn EBADDEVENGINES The developer of this package has specified the following through devEngines
warn EBADDEVENGINES Invalid engine "cpu"
warn EBADDEVENGINES Invalid name "risv" does not match "arm64" for "cpu"
warn EBADDEVENGINES Invalid name "risv" does not match "x86" for "cpu"
warn EBADDEVENGINES {
warn EBADDEVENGINES current: { name: 'arm64' },
warn EBADDEVENGINES current: { name: 'x86' },
warn EBADDEVENGINES required: { name: 'risv', onFail: 'warn' }
warn EBADDEVENGINES }
verbose stack Error: The developer of this package has specified the following through devEngines
Expand All @@ -91,12 +91,12 @@ error EBADDEVENGINES The developer of this package has specified the following t
error EBADDEVENGINES Invalid engine "runtime"
error EBADDEVENGINES Invalid name "nondescript" does not match "node" for "runtime"
error EBADDEVENGINES {
error EBADDEVENGINES current: { name: 'node', version: 'v22.5.1' },
error EBADDEVENGINES current: { name: 'node', version: 'v1337.0.0' },
error EBADDEVENGINES required: { name: 'nondescript' }
error EBADDEVENGINES }
`

exports[`test/lib/commands/install.js TAP should utilize devEngines failure case > must match snapshot 1`] = `
exports[`test/lib/commands/install.js TAP devEngines should utilize devEngines failure case > must match snapshot 1`] = `
silly config load:file:{CWD}/npmrc
silly config load:file:{CWD}/prefix/.npmrc
silly config load:file:{CWD}/home/.npmrc
Expand All @@ -117,12 +117,12 @@ error EBADDEVENGINES The developer of this package has specified the following t
error EBADDEVENGINES Invalid engine "runtime"
error EBADDEVENGINES Invalid name "nondescript" does not match "node" for "runtime"
error EBADDEVENGINES {
error EBADDEVENGINES current: { name: 'node', version: 'v22.5.1' },
error EBADDEVENGINES current: { name: 'node', version: 'v1337.0.0' },
error EBADDEVENGINES required: { name: 'nondescript' }
error EBADDEVENGINES }
`

exports[`test/lib/commands/install.js TAP should utilize devEngines failure force case > must match snapshot 1`] = `
exports[`test/lib/commands/install.js TAP devEngines should utilize devEngines failure force case > must match snapshot 1`] = `
silly config load:file:{CWD}/npmrc
silly config load:file:{CWD}/prefix/.npmrc
silly config load:file:{CWD}/home/.npmrc
Expand All @@ -137,7 +137,7 @@ warn EBADDEVENGINES The developer of this package has specified the following th
warn EBADDEVENGINES Invalid engine "runtime"
warn EBADDEVENGINES Invalid name "nondescript" does not match "node" for "runtime"
warn EBADDEVENGINES {
warn EBADDEVENGINES current: { name: 'node', version: 'v22.5.1' },
warn EBADDEVENGINES current: { name: 'node', version: 'v1337.0.0' },
warn EBADDEVENGINES required: { name: 'nondescript' }
warn EBADDEVENGINES }
silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
Expand All @@ -149,7 +149,7 @@ up to date, audited 1 package in {TIME}
found 0 vulnerabilities
`

exports[`test/lib/commands/install.js TAP should utilize devEngines success case > must match snapshot 1`] = `
exports[`test/lib/commands/install.js TAP devEngines should utilize devEngines success case > must match snapshot 1`] = `
silly config load:file:{CWD}/npmrc
silly config load:file:{CWD}/prefix/.npmrc
silly config load:file:{CWD}/home/.npmrc
Expand Down
238 changes: 126 additions & 112 deletions test/lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,133 +404,147 @@ t.test('should show install keeps dirty --workspace flag', async t => {
assert.packageInstalled('node_modules/[email protected]')
})

t.test('should utilize devEngines success case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'node',
t.test('devEngines', async t => {
const globals = {
'process.platform': 'linux',
'process.arch': 'x86',
'process.version': 'v1337.0.0',
}

t.test('should utilize devEngines success case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
globals,
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'node',
},
},
},
}),
},
}),
},
})
await npm.exec('install', [])
t.matchSnapshot(joinedFullOutput())

Check failure on line 430 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.17.0

must match snapshot

Check failure on line 430 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

must match snapshot

Check failure on line 430 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.5.0

must match snapshot

Check failure on line 430 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

must match snapshot

Check failure on line 430 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

must match snapshot
})
await npm.exec('install', [])
t.matchSnapshot(joinedFullOutput())
})

t.test('should utilize devEngines failure case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'nondescript',
t.test('should utilize devEngines failure case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
globals,
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'nondescript',
},
},
},
}),
},
}),
},
})
await t.rejects(
npm.exec('install', [])
)
t.matchSnapshot(joinedFullOutput())
})
await t.rejects(
npm.exec('install', [])
)
t.matchSnapshot(joinedFullOutput())
})

t.test('should utilize devEngines failure force case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
config: {
force: true,
},
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'nondescript',
t.test('should utilize devEngines failure force case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
config: {
force: true,
},
globals,
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'nondescript',
},
},
},
}),
},
}),
},
})
await npm.exec('install', [])
t.matchSnapshot(joinedFullOutput())

Check failure on line 473 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.17.0

must match snapshot

Check failure on line 473 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

must match snapshot

Check failure on line 473 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.5.0

must match snapshot

Check failure on line 473 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

must match snapshot

Check failure on line 473 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

must match snapshot
})
await npm.exec('install', [])
t.matchSnapshot(joinedFullOutput())
})

t.test('should utilize devEngines 2x warning case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'nondescript',
onFail: 'warn',
},
cpu: {
name: 'risv',
onFail: 'warn',
t.test('should utilize devEngines 2x warning case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
globals,
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'nondescript',
onFail: 'warn',
},
cpu: {
name: 'risv',
onFail: 'warn',
},
},
},
}),
},
}),
},
})
await npm.exec('install', [])
t.matchSnapshot(joinedFullOutput())

Check failure on line 497 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.17.0

must match snapshot

Check failure on line 497 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

must match snapshot

Check failure on line 497 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.5.0

must match snapshot

Check failure on line 497 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

must match snapshot

Check failure on line 497 in test/lib/commands/install.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

must match snapshot
})
await npm.exec('install', [])
t.matchSnapshot(joinedFullOutput())
})

t.test('should utilize devEngines 2x error case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'nondescript',
onFail: 'error',
},
cpu: {
name: 'risv',
onFail: 'error',
t.test('should utilize devEngines 2x error case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
globals,
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'nondescript',
onFail: 'error',
},
cpu: {
name: 'risv',
onFail: 'error',
},
},
},
}),
},
}),
},
})
await t.rejects(
npm.exec('install', [])
)
t.matchSnapshot(joinedFullOutput())
})
await t.rejects(
npm.exec('install', [])
)
t.matchSnapshot(joinedFullOutput())
})

t.test('should utilize devEngines failure and warning case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'nondescript',
},
cpu: {
name: 'risv',
onFail: 'warn',
t.test('should utilize devEngines failure and warning case', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
globals,
prefixDir: {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: {
runtime: {
name: 'nondescript',
},
cpu: {
name: 'risv',
onFail: 'warn',
},
},
},
}),
},
}),
},
})
await t.rejects(
npm.exec('install', [])
)
t.matchSnapshot(joinedFullOutput())
})
await t.rejects(
npm.exec('install', [])
)
t.matchSnapshot(joinedFullOutput())
})

0 comments on commit 219bb83

Please sign in to comment.