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 are failing on windows and LTS node v12.19.0

See original GitHub issue

I recently got a windows machine and the tests are failing when executed.

FAIL  src/tests/server.ts
  ● Connect › should not close the socket after the `connectionInitWaitTimeout` has passed but the callback is still resolving

    expect.assertions(2)

    Expected two assertions to be called but received one assertion call.

      268 | 
      269 |   it('should not close the socket after the `connectionInitWaitTimeout` has passed but the callback is still resolving', async () => {
    > 270 |     expect.assertions(2);
          |            ^
      271 | 
      272 |     await makeServer({
      273 |       connectionInitWaitTimeout: 10,

      at Object.<anonymous> (src/tests/server.ts:270:12)

  ● Connect › should close the socket if an additional `ConnectionInit` message is received while one is pending

    expect.assertions(3)

    Expected three assertions to be called but received four assertion calls.

      298 | 
      299 |   it('should close the socket if an additional `ConnectionInit` message is received while one is pending', async () => {
    > 300 |     expect.assertions(3);
          |            ^
      301 | 
      302 |     await makeServer({
      303 |       connectionInitWaitTimeout: 10,

      at Object.<anonymous> (src/tests/server.ts:300:12)

 FAIL  src/tests/client.ts
  ● "concurrency" › should dispatch and receive messages even if one subscriber disposes while another one subscribes

    expect(jest.fn()).toBeCalled()

    Expected number of calls: >= 1
    Received number of calls:    0

      399 |     expect(nextFnForHappy).not.toBeCalled();
      400 |     expect(completeFnForHappy).toBeCalled();
    > 401 |     expect(nextFnForBananas).toBeCalled();
          |                              ^
      402 |   });
      403 | });
      404 | 

      at Object.<anonymous> (src/tests/client.ts:401:30)

  ● lazy › should connect immediately when mode is disabled

    expect(received).toBe(expected) // Object.is equality

    Expected: 1
    Received: 2

      411 |     await wait(10);
      412 | 
    > 413 |     expect(server.webSocketServer.clients.size).toBe(1);
          |                                                 ^
      414 |     server.webSocketServer.clients.forEach((client) => {
      415 |       expect(client.readyState).toBe(WebSocket.OPEN);
      416 |     });

      at Object.<anonymous> (src/tests/client.ts:413:49)

Test Suites: 2 failed, 2 total
Tests:       4 failed, 1 todo, 37 passed, 42 total
Snapshots:   0 total
Time:        4.138 s
Ran all test suites.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
n1ru4lcommented, Oct 19, 2020

Instead of waiting it might be the better solution to create a deferred promise e.g.:

const createDeferred = () => {
  let d = {};
  const promise = new Promise((resolve, reject) => {
    d = { resolve, reject };
  });
  return { ...d, promise } as {
    resolve: () => void;
    reject: (err: unknown) => void;
    promise: Promise<void>;
  };
};
  await makeServer();

  const d = createDeferred()

  let client = new WebSocket(url);
  client.onclose = (event) => {
    expect(event.code).toBe(1002);
    expect(event.reason).toBe('Protocol Error');
    expect(event.wasClean).toBeTruthy();
    d.resolve()
  };

  await d.promise

This has the drawback of the test being stuck until the maximum runtime per test is reached in case the promise is never resolved, but it prevents test case leaking to some extend.

Maybe it would also make more sense to start and tear down the server on a test case level in order to additionally prevent invalid states that leak into the next test case if a single test case fails or is not cleaned up correctly? That will probably increase testing time, but pooling might fix the impact (start 10 servers on 10 different ports; shut down recreate one after each test case etc).

1reaction
n1ru4lcommented, Oct 19, 2020

I will tackle this 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can not `npm test` on Windows, node version 12.13.0 (LTS)
After cloning, I ran npm install. I tried running npm test, but got an error. Full output: C:\Users\soryy\Documents\Software ...
Read more >
Node v12.19.0 (LTS)
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
Read more >
npm does not support Node.js v12.18.3 - Stack Overflow
I've installed the latest version of Node.js (12.18.3) on my Windows 10 PC and I'm trying to install a package using npm. When...
Read more >
Node_js lts/* failing on Windows - Node.js - Travis CI Community
I think node is not a valid name on Windows (which uses a different Node. js version manager) when it comes to Travis....
Read more >
NodeTool@0 - Node.js tool installer v0 task | Microsoft Learn
Finds or downloads and caches the specified version spec of Node.js and adds it to the PATH.
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