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

Error running jest tests with v0.13.1 #71

Closed
jjhamshaw opened this issue May 29, 2020 · 2 comments
Closed

Error running jest tests with v0.13.1 #71

jjhamshaw opened this issue May 29, 2020 · 2 comments

Comments

@jjhamshaw
Copy link

jjhamshaw commented May 29, 2020

(I've created a repo with the issue, so it can be reproduced: https://github.com/jjhamshaw/colyseus-example)

Steps to reproduce

  • create a fresh create-react-app
  • install colyseus@0.13.1
  • create a new instance of a Room in a test
  • run yarn test

I'm getting this error with from nanoEvents (there's a test in the example repo to show this here):

TypeError: nanoevents_1.createNanoEvents is not a function

      2 |
      3 | test("this should work", () => {
    > 4 |   const room = new Room("name");
        |                ^
      5 |   expect(room).toBeDefined();
      6 | });
      7 |

note: colyseus@0.13.0 works as expected

@endel
Copy link
Member

endel commented May 29, 2020

Thanks for reporting @jjhamshaw, I found this other issue that's related to what you're describing here: ai/nanoevents#45

Not really sure what we can do to fix this. It seems to me that the entire Node.js / NPM ecosystem is moving towards cjs / module pattern and the existing tooling is not keeping up with that. Here's a similar issue with a different dependency and environment #64

I think colyseus.js should provide alternative entry points on its package.json for better integration with modern browser/node/cjs/whatever environments.

@jjhamshaw
Copy link
Author

@endel thanks for the quick reply (unlike mine...).

Got it, the issue is clearly not with colyseus but with tooling i.e. jest. I don't actually need to create an instance of a Room now, instead I'm just mocking it - so kind of a workaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants