Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test fails when excuting the unit test in Windows OS #2594

Closed
jennynju opened this issue Dec 9, 2019 · 6 comments
Closed

Unit test fails when excuting the unit test in Windows OS #2594

jennynju opened this issue Dec 9, 2019 · 6 comments

Comments

@jennynju
Copy link
Contributor

@jennynju jennynju commented Dec 9, 2019

Describe the bug
Unit test case failed :

  1. supports http with nodejs
    should pass errors for a failed stream:
    Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (***************...

To Reproduce
Use VS Code internal terminal to excute the unit test .

Expected behavior
UT should be excuted correctly.

Environment:

  • Axios Version: latest master
  • OS Version: Window 10

Additional context/Screenshots
Capture

@chinesedfan
Copy link
Collaborator

@chinesedfan chinesedfan commented Dec 10, 2019

@jennynju Find why your test case didn't finished before timeout. And in your screenshot, there is a "no such file" error. Please provide the detailed codes of your test case.

@jennynju
Copy link
Contributor Author

@jennynju jennynju commented Dec 11, 2019

The failure happens when I excute npm run test and the failed test case is : 'should pass errors for a failed stream' in \unit\adapters\http.js.

 it('should pass errors for a failed stream', function (done) {
    server = http.createServer(function (req, res) {
      req.pipe(res);
    }).listen(4444, function () {
      axios.post('http://localhost:4444/',
        fs.createReadStream('/does/not/exist')
      ).then(function (res) {
        assert.fail();
      }).catch(function (err) {
        assert.equal(err.message, 'ENOENT: no such file or directory, open \'/does/not/exist\'');
        done();
      });
    });
  });

It failed at the assertion:
AssertionError [ERR_ASSERTION]: 'ENOENT: no such file or directory, open 'C:\\does\\not\\exist'' == 'ENOENT: no such file or directory, open '/does/not/exist''.

I think the reason is the NODE PATH format various in different environment. I'd prefer use the default node path for this test in order to escape from different environment factors.

jennynju added a commit to jennynju/axios that referenced this issue Dec 11, 2019
@chinesedfan
Copy link
Collaborator

@chinesedfan chinesedfan commented Dec 11, 2019

@jennynju I just noticed that you are running our unit tests. In fact, the CI is passed. So there should be some problem in your local environment. The ENOENT is generated as expected. The most possible reason is that port 4444 is in use by other programs. Try to use another port.

@jennynju
Copy link
Contributor Author

@jennynju jennynju commented Dec 11, 2019

@chinesedfan, FYI, it has nothing to do with the port.
Actually the issue is caused by the differences between OS systems. In Windows, path does use '/' as delimiter.
As a result, this unit test will only pass in linux-like OS system.

@jennynju jennynju changed the title Unit test fails when use VS Code to excute the unit test Unit test fails when excuting the unit test in Windows OS Dec 11, 2019
@chinesedfan
Copy link
Collaborator

@chinesedfan chinesedfan commented Dec 11, 2019

@jennynju I see. We can only check the beginning part of the error message and ignore the file path. PR welcome.

@jennynju
Copy link
Contributor Author

@jennynju jennynju commented Dec 12, 2019

@chinesedfan , thanks for your comments.
I was thinking about using "__dirname" to construct the 'do not exist' folder to keep consistency between different OS systems. PR was submitted.

jennynju added a commit to jennynju/axios that referenced this issue Feb 3, 2020
@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.