From 9267d4def1a3c65b2d2bbb051b11d74f25ea00ae Mon Sep 17 00:00:00 2001 From: jennynju <46782518+jennynju@users.noreply.github.com> Date: Sat, 15 Feb 2020 19:03:34 +0800 Subject: [PATCH] Fixing unit test failure in Windows OS (#2601) Co-authored-by: Xianming Zhong --- test/unit/adapters/http.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js index 6e9c57f..7e02c79 100644 --- a/test/unit/adapters/http.js +++ b/test/unit/adapters/http.js @@ -5,6 +5,7 @@ var url = require('url'); var zlib = require('zlib'); var assert = require('assert'); var fs = require('fs'); +var path = require('path'); var server, proxy; describe('supports http with nodejs', function () { @@ -304,15 +305,17 @@ describe('supports http with nodejs', function () { }); it('should pass errors for a failed stream', function (done) { + var notExitPath = path.join(__dirname, 'does_not_exist'); + server = http.createServer(function (req, res) { req.pipe(res); }).listen(4444, function () { axios.post('http://localhost:4444/', - fs.createReadStream('/does/not/exist') + fs.createReadStream(notExitPath) ).then(function (res) { assert.fail(); }).catch(function (err) { - assert.equal(err.message, 'ENOENT: no such file or directory, open \'/does/not/exist\''); + assert.equal(err.message, `ENOENT: no such file or directory, open \'${notExitPath}\'`); done(); }); });