Skip to content

Commit d842dca

Browse files
committed
chore: attempt at test for extraneous dependancies
1 parent 09ad624 commit d842dca

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

workspaces/arborist/test/arborist/build-ideal-tree.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4091,3 +4091,67 @@ t.test('should take devEngines in account', async t => {
40914091
const tree = await buildIdeal(path)
40924092
t.matchSnapshot(String(tree.meta))
40934093
})
4094+
4095+
t.test(
4096+
'extraneous dependency not buildable on current platform does not throw',
4097+
async (t) => {
4098+
const isLinux = process.platform === 'linux'
4099+
const incompatibleOS = isLinux ? 'darwin' : 'linux'
4100+
4101+
const path = t.testdir({
4102+
'package.json': JSON.stringify({
4103+
name: 'extraneous-test',
4104+
version: '1.0.0',
4105+
dependencies: {
4106+
'dependency-with-shrinkwrap': '1.0.0',
4107+
},
4108+
}),
4109+
'package-lock.json': JSON.stringify({
4110+
name: 'extraneous-test',
4111+
version: '1.0.0',
4112+
lockfileVersion: 3,
4113+
requires: true,
4114+
packages: {
4115+
'': {
4116+
name: 'extraneous-test',
4117+
version: '1.0.0',
4118+
dependencies: {
4119+
'dependency-with-shrinkwrap': '^1.0.0',
4120+
},
4121+
},
4122+
'node_modules/dependency-with-shrinkwrap': {
4123+
version: '1.0.0',
4124+
hasShrinkwrap: true,
4125+
dependencies: {},
4126+
},
4127+
'node_modules/dependency-with-shrinkwrap/node_modules/dev-dependency':
4128+
{
4129+
version: '1.0.0',
4130+
extraneous: true,
4131+
optionalDependencies: {
4132+
'optional-dependancy': '1.0.0',
4133+
},
4134+
},
4135+
'node_modules/dependency-with-shrinkwrap/node_modules/optional-dependancy':
4136+
{
4137+
version: '1.0.0',
4138+
cpu: ['x64'],
4139+
extraneous: true,
4140+
os: [incompatibleOS],
4141+
},
4142+
},
4143+
}),
4144+
})
4145+
4146+
createRegistry(t, false)
4147+
const arb = newArb(path)
4148+
4149+
try {
4150+
await arb.buildIdealTree({ prune: false })
4151+
} catch (e) {
4152+
t.fail(
4153+
'should not throw for extraneous dependency not buildable on this platform'
4154+
)
4155+
}
4156+
}
4157+
)

0 commit comments

Comments
 (0)