diff --git a/test/lib/publish.js b/test/lib/publish.js index 6a4c6e0ab707c..e34f00b477ee1 100644 --- a/test/lib/publish.js +++ b/test/lib/publish.js @@ -732,5 +732,33 @@ t.test('private workspaces', (t) => { }) }) + t.test('unexpected error', t => { + const Publish = t.mock('../../lib/publish.js', { + ...mocks, + libnpmpublish: { + publish: (manifest, tarballData, opts) => { + if (manifest.private) + throw new Error('ERR') + + publishes.push(manifest) + }, + }, + npmlog: { + notice () {}, + verbose () {}, + }, + }) + const publish = new Publish(npm) + + publish.execWorkspaces([], [], (err) => { + t.match( + err, + /ERR/, + 'should throw unexpected error' + ) + t.end() + }) + }) + t.end() })