question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tests fail on Node 6

See original GitHub issue

Node’s net library has a breaking change in Node 6, which performs validation on the port in the listen method.

~/Repos/koala → npm test

> koala@1.0.0 test /Users/nick/Repos/koala
> NODE_ENV=test mocha --reporter spec --timeout 30s --bail test/app/index.js

internal/net.js:17
    throw new RangeError('"port" argument must be >= 0 and < 65536');
    ^

RangeError: "port" argument must be >= 0 and < 65536
    at assertPort (internal/net.js:17:11)
    at Server.listen (net.js:1384:5)
    at Application.listen (/Users/nick/Repos/koala/lib/app.js:19:12)
    at Suite.<anonymous> (/Users/nick/Repos/koala/test/app/conditional-get.js:11:22)
    at context.describe.context.context (/Users/nick/Repos/koala/node_modules/mocha/lib/interfaces/bdd.js:47:10)
    at Suite.<anonymous> (/Users/nick/Repos/koala/test/app/conditional-get.js:3:3)
    at context.describe.context.context (/Users/nick/Repos/koala/node_modules/mocha/lib/interfaces/bdd.js:47:10)
    at Object.<anonymous> (/Users/nick/Repos/koala/test/app/conditional-get.js:2:1)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
npm ERR! Test failed.  See above for more details.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
doug-wadecommented, Sep 3, 2017

This seems to be specific to node 6

i-200077 foss/koala ‹master*› » node -v
v8.4.0
i-200077 foss/koala ‹master*› » npm test

> koala@1.0.0 test /Users/dwade/foss/koala
> NODE_ENV=test mocha --reporter spec --timeout 30s --bail test/app/index.js



  Basic Auth
    ✓ should return the value

  Body Parsing
    .request.json()
      ✓ should parse a json body
      ✓ should throw on non-objects in strict mode
      ✓ should not throw on non-objects in non-strict mode
    .request.urlencoded()
      ✓ should parse a urlencoded body
      ✓ should not support nested query strings by default
      ✓ should support nested query strings with options.qs=true
    .request.text()
      ✓ should get the raw text body
      ✓ should throw if the body is too large
    .request.buffer()
      ✓ should get the raw buffer body
      ✓ should throw if the body is too large
    Expect: 100-continue
      ✓ should send 100-continue

  Cache-Control
    should be available as
      ✓ this.cc()
      ✓ this.cacheControl()
      ✓ this.response.cc()
      ✓ this.cacheControl()
    when the value is a number
      ✓ should set "public, max-age="
    when the value is a time string
      ✓ should set "public, max-age="
    when the value is "false"
      ✓ should set "private, no-cache"
    when the value is a string
      ✓ should juset set it
    when the value is anything else
      ✓ should throw

  Conditional-Get
    when a body is set
      ✓ should set an etag
      ✓ should response 304 w/ if-none-match header

  Set headers
    X-Response-Time
      ✓ should get X-Response-Time correctly by default
      ✓ should not get X-Response-Time by options.responseTime = false
    X-Frame-Options
      ✓ should get X-Frame-Options DENY by default
      ✓ should not get X-Frame-Options by xframe = false
      ✓ should get X-Frame-Options DENY by xframe = true
      ✓ should get X-Frame-Options SAMEORIGIN by xframe = same

  jsonp
    ✓ should return jsonp response
    ✓ should return json response

  Middlewares
    Session
      ✓ should has this.session by default
      ✓ should has no this.session by options.session = false

  Object Streams
    ✓ should be supported

  Polyfills
    GET /polyfill.js
      - should return the polyfill

  Nested Query Strings
    when options.qs = false
      ✓ should not support nested query strings
    when options.qs = true
      ✓ should support nested query strings


  36 passing (280ms)
  1 pending
0reactions
nickmccurdycommented, Sep 4, 2017

Good catch. See #37 for troubleshooting, it’s only failing on 6. I would definitely still want to fix this because it’s the current LTS version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit tests fail on Node.js v14.x and v15.x - Check ... - GitHub
When using the latest Node.js LTS Fermium v14.15.0, the unit test began to fail consistently and it also reproduces on v15.x versions.
Read more >
Tests randomly failing with jest and node - Stack Overflow
When running this test, it sometimes fails with res.code being 0 instead of 127. When testing without jest, it works flawlessly 100% of...
Read more >
Testing Error Handling in node.js | by Lars Trieloff
Testing Error Handling in node.js · 1. Don't let yourself get away with less than 100% · 2. Always assert the exception ·...
Read more >
Test runner with Nodejs and Jest not working with 17.1
Anyways, I was able to get basic tests running and showing fail messages with a couple simple changes. I do not guarantee this...
Read more >
Mocha - the fun, simple, flexible JavaScript test framework
simple, flexible, fun. Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found