Skip to content

Commit 5e15690

Browse files
committed
test: update arborist test for thin wrapper architecture
1 parent 2f7b8c8 commit 5e15690

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

test/unit/build-externals.test.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,26 +225,36 @@ describe('build-externals', () => {
225225

226226
it('should have @npmcli/arborist properly bundled', async () => {
227227
const arboristPath = path.join(distExternalDir, '@npmcli', 'arborist.js')
228+
const npmPackPath = path.join(distExternalDir, 'npm-pack.js')
228229

229230
try {
230-
const [stat, content] = await Promise.all([
231+
const [arboristStat, arboristContent, npmPackStat] = await Promise.all([
231232
fs.stat(arboristPath),
232233
fs.readFile(arboristPath, 'utf8'),
234+
fs.stat(npmPackPath),
233235
])
234236

235-
// Arborist is a large package, should be substantially bundled
236-
if (stat.size <= 1000) {
237+
// Arborist should be a thin wrapper re-exporting from npm-pack
238+
if (arboristStat.size > 500) {
237239
expect.fail(
238-
`@npmcli/arborist should be properly bundled (> 1KB), got ${stat.size} bytes`,
240+
`@npmcli/arborist should be a thin wrapper (< 500B), got ${arboristStat.size} bytes`,
239241
)
240242
}
241243

242-
if (isStubReexport(content)) {
243-
expect.fail('@npmcli/arborist should not be a stub re-export')
244+
// Should re-export from npm-pack bundle
245+
if (!arboristContent.includes("require('../npm-pack')")) {
246+
expect.fail('@npmcli/arborist should re-export from npm-pack bundle')
247+
}
248+
249+
// npm-pack bundle should contain arborist
250+
if (npmPackStat.size <= 1_000_000) {
251+
expect.fail(
252+
`npm-pack.js should be a large bundle (> 1MB), got ${npmPackStat.size} bytes`,
253+
)
244254
}
245255
} catch (error) {
246256
expect.fail(
247-
`@npmcli/arborist not found or not properly bundled at ${arboristPath}: ${error instanceof Error ? error.message : String(error)}`,
257+
`@npmcli/arborist not found or not properly configured at ${arboristPath}: ${error instanceof Error ? error.message : String(error)}`,
248258
)
249259
}
250260
})

0 commit comments

Comments
 (0)