Skip to content

Tests fail with latest version of Mocha #3710

@Download

Description

@Download

You want to:

  • report a bug
  • request a feature

Current behaviour

When running the tests under the latest version of Mocha, some of them fail.

Steps to reproduce (if the current behavior is a bug)

  • Git clone this repo
  • npm install
  • Observe that vulnerabilities are mentioned; these vulnerabilities come from Mocha
  • npm outdated to show the list of outdated dependencies
  • Update all dependencies except for Mocha and Prettier to their latest versions (see Update most dependencies #3711)
  • npm test
  • Observe: all tests succeed
  • npm uninstall --save-dev mocha && npm install --save-dev mocha
  • npm test
  • Observe: some tests fail
C:\ws\socketio>npm outdated
Package   Current  Wanted  Latest  Location
mocha       3.5.3   3.5.3   8.2.1  socket.io
prettier   1.19.1  1.19.1   2.2.0  socket.io

C:\ws\socketio>npm uninstall --save-dev mocha && npm install --save-dev mocha
removed 24 packages and audited 303 packages in 2.142s

21 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ mocha@8.2.1
added 57 packages from 31 contributors and audited 361 packages in 6.574s

31 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


C:\ws\socketio>npm test

> socket.io@3.0.3 test C:\ws\socketio
> npm run format:check && npm run compile && nyc mocha --require ts-node/register --reporter spec --slow 200 --bail --timeout 10000 test/socket.io.ts


> socket.io@3.0.3 format:check C:\ws\socketio
> prettier --check "lib/**/*.ts" "test/**/*.ts"

Checking formatting...
All matched files use Prettier code style!

> socket.io@3.0.3 compile C:\ws\socketio
> rimraf ./dist && tsc



  socket.io
    √ should be the same version as client
    server attachment
      http.Server
        √ should serve client
        √ should serve source map
        √ should serve client (min)
        √ should serve source map (min)
        √ should serve client (gzip)
        √ should serve bundle with msgpack parser
        √ should serve source map for bundle with msgpack parser
        √ should handle 304
        √ should not serve static files
        √ should work with #attach
        √ should work with #attach (and merge options)
      port
        √ should be bound
        √ should be bound as a string
        √ with listen
        √ as a string
    handshake
      √ should send the Access-Control-Allow-xxx headers on OPTIONS request
      √ should send the Access-Control-Allow-xxx headers on GET request
      √ should allow request if custom function in opts.allowRequest returns true
      √ should disallow request if custom function in opts.allowRequest returns false
    close
      √ should be able to close sio sending a srv
      √ should be able to close sio sending a port
      1) should be able to close sio sending a port


  22 passing (433ms)
  1 failing

  1) socket.io
       close
         should be able to close sio sending a port:
     Uncaught TypeError: Cannot read property 'sockets' of undefined
      at Socket.clientSocket.on (test\socket.io.ts:292:43)
      at Socket.Emitter.emit (node_modules\component-emitter\index.js:145:20)
      at Socket.onconnect (node_modules\socket.io-client\build\socket.js:291:15)
      at Socket.onpacket (node_modules\socket.io-client\build\socket.js:190:22)
      at Manager.<anonymous> (node_modules\component-bind\index.js:21:15)
      at Manager.Emitter.emit (node_modules\component-emitter\index.js:145:20)
      at Manager.ondecoded (node_modules\socket.io-client\build\manager.js:209:15)
      at Decoder.<anonymous> (node_modules\component-bind\index.js:21:15)
      at Decoder.Emitter.emit (node_modules\component-emitter\index.js:145:20)
      at Decoder.add (node_modules\socket.io-parser\dist\index.js:117:23)
      at Manager.ondata (node_modules\socket.io-client\build\manager.js:201:22)
      at Socket.<anonymous> (node_modules\component-bind\index.js:21:15)
      at Socket.Emitter.emit (node_modules\component-emitter\index.js:145:20)
      at Socket.onPacket (node_modules\engine.io-client\lib\socket.js:388:16)
      at XHR.<anonymous> (node_modules\engine.io-client\lib\socket.js:197:14)
      at XHR.Emitter.emit (node_modules\component-emitter\index.js:145:20)
      at XHR.onPacket (node_modules\engine.io-client\lib\transport.js:103:10)
      at callback (node_modules\engine.io-client\lib\transports\polling.js:101:12)
      at Array.forEach (<anonymous>)
      at XHR.onData (node_modules\engine.io-client\lib\transports\polling.js:105:56)
      at Request.<anonymous> (node_modules\engine.io-client\lib\transports\polling-xhr.js:95:12)
      at Request.Emitter.emit (node_modules\component-emitter\index.js:145:20)
      at Request.onData (node_modules\engine.io-client\lib\transports\polling-xhr.js:236:10)
      at Request.onLoad (node_modules\engine.io-client\lib\transports\polling-xhr.js:287:12)
      at XMLHttpRequest.xhr.onreadystatechange (node_modules\engine.io-client\lib\transports\polling-xhr.js:191:18)
      at XMLHttpRequest.dispatchEvent (node_modules\xmlhttprequest-ssl\lib\XMLHttpRequest.js:622:25)
      at setState (node_modules\xmlhttprequest-ssl\lib\XMLHttpRequest.js:641:14)
      at IncomingMessage.<anonymous> (node_modules\xmlhttprequest-ssl\lib\XMLHttpRequest.js:480:13)
      at endReadableNT (_stream_readable.js:1145:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



C:\ws\socketio\node_modules\mocha\lib\runner.js:962
    throw err;
    ^

TypeError: Cannot read property 'sockets' of undefined
    at Socket.clientSocket.on (C:\ws\socketio\test\socket.io.ts:318:43)
    at Socket.Emitter.emit (C:\ws\socketio\node_modules\component-emitter\index.js:145:20)
    at Socket.onconnect (C:\ws\socketio\node_modules\socket.io-client\build\socket.js:291:15)
    at Socket.onpacket (C:\ws\socketio\node_modules\socket.io-client\build\socket.js:190:22)
    at Manager.<anonymous> (C:\ws\socketio\node_modules\component-bind\index.js:21:15)
    at Manager.Emitter.emit (C:\ws\socketio\node_modules\component-emitter\index.js:145:20)
    at Manager.ondecoded (C:\ws\socketio\node_modules\socket.io-client\build\manager.js:209:15)
    at Decoder.<anonymous> (C:\ws\socketio\node_modules\component-bind\index.js:21:15)
    at Decoder.Emitter.emit (C:\ws\socketio\node_modules\component-emitter\index.js:145:20)
    at Decoder.add (C:\ws\socketio\node_modules\socket.io-parser\dist\index.js:117:23)
    at Manager.ondata (C:\ws\socketio\node_modules\socket.io-client\build\manager.js:201:22)
    at Socket.<anonymous> (C:\ws\socketio\node_modules\component-bind\index.js:21:15)
    at Socket.Emitter.emit (C:\ws\socketio\node_modules\component-emitter\index.js:145:20)
    at Socket.onPacket (C:\ws\socketio\node_modules\engine.io-client\lib\socket.js:388:16)
    at XHR.<anonymous> (C:\ws\socketio\node_modules\engine.io-client\lib\socket.js:197:14)
    at XHR.Emitter.emit (C:\ws\socketio\node_modules\component-emitter\index.js:145:20)
    at XHR.onPacket (C:\ws\socketio\node_modules\engine.io-client\lib\transport.js:103:10)
    at callback (C:\ws\socketio\node_modules\engine.io-client\lib\transports\polling.js:101:12)
    at Array.forEach (<anonymous>)
    at XHR.onData (C:\ws\socketio\node_modules\engine.io-client\lib\transports\polling.js:105:56)
    at Request.<anonymous> (C:\ws\socketio\node_modules\engine.io-client\lib\transports\polling-xhr.js:95:12)
    at Request.Emitter.emit (C:\ws\socketio\node_modules\component-emitter\index.js:145:20)
    at Request.onData (C:\ws\socketio\node_modules\engine.io-client\lib\transports\polling-xhr.js:236:10)
    at Request.onLoad (C:\ws\socketio\node_modules\engine.io-client\lib\transports\polling-xhr.js:287:12)
    at XMLHttpRequest.xhr.onreadystatechange (C:\ws\socketio\node_modules\engine.io-client\lib\transports\polling-xhr.js:191:18)
    at XMLHttpRequest.dispatchEvent (C:\ws\socketio\node_modules\xmlhttprequest-ssl\lib\XMLHttpRequest.js:622:25)
    at setState (C:\ws\socketio\node_modules\xmlhttprequest-ssl\lib\XMLHttpRequest.js:641:14)
    at IncomingMessage.<anonymous> (C:\ws\socketio\node_modules\xmlhttprequest-ssl\lib\XMLHttpRequest.js:480:13)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |
----------|---------|----------|---------|---------|-------------------
npm ERR! Test failed.  See above for more details.

Other information (e.g. stacktraces, related issues, suggestions how to fix)

I'm a bit stumped at the moment what is going on here, so not preparing a PR (yet).

See #3709

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions