zendesk / laika

Log, test, intercept and modify Apollo Client's operations
https://zendesk.github.io/laika
Apache License 2.0
122 stars 7 forks source link

Error in Unit test #12

Open trevlar opened 2 years ago

trevlar commented 2 years ago

I'm seeing an error in my unit tests after adding Laika.

 import noop from 'lodash/noop';
    ^^^^^^

SyntaxError: Cannot use import statement outside a module

To produce this error I followed the instructions in the documentation.

Then I followed the instructions on linking it in a unit test.

https://zendesk.github.io/laika/docs/how-to-install/#loading-the-link-in-unit-tests

I am using TypeScript and have lodash as a dependency of my project.

WonderPanda commented 2 years ago

@trevlar Depending on your setup you probably want to import from @zendesk/laika/cjs/laika instead of @zendesk/laika/esm/laika since by default Jest doesn't know how to deal with ESM