diff --git a/test/parallel/test-require-invalid-package.js b/test/parallel/test-require-invalid-package.js index 45272cf5c3af9a..54ffaabe2ec3f2 100644 --- a/test/parallel/test-require-invalid-package.js +++ b/test/parallel/test-require-invalid-package.js @@ -1,9 +1,9 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); // Should be an invalid package path. -assert.throws(() => require('package.json'), (err) => { - return err && err.code === 'MODULE_NOT_FOUND'; -}); +assert.throws(() => require('package.json'), + common.expectsError('MODULE_NOT_FOUND') +);