diff --git a/lib/mkdirs/__tests__/issue-93.test.js b/lib/mkdirs/__tests__/issue-93.test.js index c8b942e0..ec0270b8 100644 --- a/lib/mkdirs/__tests__/issue-93.test.js +++ b/lib/mkdirs/__tests__/issue-93.test.js @@ -4,6 +4,7 @@ const os = require('os') const fse = require(process.cwd()) const path = require('path') const assert = require('assert') +const util = require('util') /* global before, describe, it */ @@ -23,13 +24,19 @@ describe('mkdirp: issue-93, win32, when drive does not exist, it should return a it('should return a cleaner error than inifinite loop, stack crash', done => { const file = 'R:\\afasd\\afaff\\fdfd' // hopefully drive 'r' does not exist on appveyor + // Different error codes on different Node versions (matches native mkdir behavior) + const assertErr = (err) => assert( + ['EPERM', 'ENOENT'].includes(err.code), + `expected 'EPERM' or 'ENOENT', got ${util.inspect(err.code)}` + ) + fse.mkdirp(file, err => { - assert.strictEqual(err.code, 'EPERM') + assertErr(err) try { fse.mkdirsSync(file) } catch (err) { - assert.strictEqual(err.code, 'EPERM') + assertErr(err) } done()