Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
chore: add regression tests for old lockfile warning
Browse files Browse the repository at this point in the history
Ref: npm/cli#3721

Prior to [this change](c7f2370#diff-a22bf0383032b8f318ebe49a4e41b34bcc98e2c10d18322f619edcd041a27483R333-R334)
reifying with no package-lock or a package-lock with a merge conflict
would result in an old lockfile warning. This adds regression tests to
explicitly test both those scenarios.
  • Loading branch information
lukekarrys committed Oct 22, 2021
1 parent d9c603e commit 6b33eb1
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,52 @@ t.test('complete build for project with old lockfile', async t => {
])
})

t.test('no old lockfile warning with no package-lock', async t => {
const fixt = t.testdir({
node_modules: {
abbrev: {
'package.json': JSON.stringify({
name: 'abbrev',
version: '1.1.1',
}),
},
},
'package.json': JSON.stringify({
name: 'no-package-lock',
dependencies: {
abbrev: '1',
},
}),
})
const checkLogs = warningTracker()
await newArb(fixt).reify()
t.strictSame(checkLogs(), [])
})

t.test('no old lockfile warning with a conflict package-lock', async t => {
const fixt = t.testdir({
node_modules: {
abbrev: {
'package.json': JSON.stringify({
name: 'abbrev',
version: '1.1.1',
}),
},
},
'package.json': JSON.stringify({
name: 'conflict-package-lock',
dependencies: {
abbrev: '1',
},
}),
'package-lock.json': fs.readFileSync(resolve(fixtures, 'conflict-package-lock', 'package-lock.json'))
})

const checkLogs = warningTracker()
await newArb(fixt).reify()
t.strictSame(checkLogs(), [])
})

t.test('override a conflict with the root dep (with force)', async t => {
const path = resolve(fixtures, 'testing-peer-dep-conflict-chain/override')
// note: fails because this is the root dep, unless --force used
Expand Down
30 changes: 30 additions & 0 deletions test/fixtures/conflict-package-lock/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6b33eb1

Please sign in to comment.