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

[RAC-6232]Node 6/8 unit test fix #800

Merged
merged 1 commit into from
Nov 2, 2017
Merged

[RAC-6232]Node 6/8 unit test fix #800

merged 1 commit into from
Nov 2, 2017

Conversation

mcgG
Copy link
Contributor

@mcgG mcgG commented Oct 26, 2017

Background

Currently, unit test will fail in Nodejs 6 and Nodejs 8.
https://rackhd.atlassian.net/browse/RAC-6232

AC:

  • Paired with @PengTian0
  • Fix nodejs6 unit test failures in local machine
  • Don’t break nodejs 4 unit test
  • Pilot run in travisci environment(don’t commit the fix, because further FIT test should pass before submitting

Detail

About case Http.Server rest().should 500 if a deserializer returns a rejected promise (from Mocha Tests)
AssertionError: expected 'err.toString(...).contains is not a function' to equal 'deserializer reject!' at spec/lib/services/rest-api-service-spec.js:418:31 at Test._assertFunction (node_modules/supertest/lib/test.js:247:11) at Test.assert (node_modules/supertest/lib/test.js:148:18) at assert (node_modules/supertest/lib/test.js:127:12) at node_modules/supertest/lib/test.js:124:5 at Test.Request.callback (node_modules/superagent/lib/node/index.js:703:3) at IncomingMessage.<anonymous> (node_modules/superagent/lib/node/index.js:922:12) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickDomainCallback (internal/process/next_tick.js:128:9)

  • Cause:
    traceur(0.0.33) override String and provides "contains()" function. But new version of traceur doesn't provide that.
  • Fix:
    Change "contains()" to "includes()"

About case Http.Server rest() should 400 when POSTing bad JSON
AssertionError: expected 'Error parsing JSON: Unexpected token b in JSON at position 1' to equal 'Error parsing JSON: Unexpected token b'
*Cause:
In Node4 the return error message is
Error parsing JSON: Unexpected token b
But in Node6
Error parsing JSON: Unexpected token b in JSON at position 1
*Fix:
Use
.to.match(/Error parsing JSON: Unexpected token b.*/)
Instead of
.to.equal('Error parsing JSON: Unexpected token b')

About case Http.Api.Users should 201 a user post attempt with localexception
Error: expected { username: 'admin', role: 'Administrator' } response body, got { message: 'parsed_url.query.hasOwnProperty is not a function', status: '400', UUID: 'c7a85886-0d25-4cf3-b761-491c42397eda' } + expected - actual { - "UUID": "c7a85886-0d25-4cf3-b761-491c42397eda" - "message": "parsed_url.query.hasOwnProperty is not a function" - "status": "400" + "role": "Administrator" + "username": "admin" }
*Cause:
Third party module bug
*Fix:
Update passport-jwt@2.0.0 to passport-jwt@3.0.0

For case AssertionError
This is the same issue with on-tasks
Change

  • spec/lib/services/hooks-api-service-spec.js:L76
  • spec/lib/services/nodes-api-service-spec.js:L1165, 1183, 1207
  • spec/lib/services/rest-api-service-spec.js:L139

expect(err.name).equals('xxx'); {code}
expect(err.name).match(/xxx.*/);

@iceiilin @anhou @pengz1 @bbcyyb @PengTian0

@JenkinsRHD
Copy link
Contributor

BUILD on-http #636 : FAILURE

@anhou anhou merged commit c369964 into RackHD:master Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants