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

Cannot use import statement outside a module, Jest #553

Closed
net-illia-stetsenko opened this issue Dec 22, 2023 · 1 comment
Closed

Cannot use import statement outside a module, Jest #553

net-illia-stetsenko opened this issue Dec 22, 2023 · 1 comment

Comments

@net-illia-stetsenko
Copy link

Hello there
Faced with a problem when tried to test my ky client.
I use Jest for testing. After running the tests I have received the following error:

node_modules/ky/distribution/index.js:2
    import { Ky } from './core/Ky.js';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

    > 1 | import ky, { KyInstance } from 'ky';
        | ^
      2 |
      3 | import logger from '../logger';
      4 |

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
      at Object.<anonymous> (src/client/api.ts:1:1)
      at Object.<anonymous> (tests/api-tests/v1/get.test.ts:3:1)

Thought, vite is succesfully builds the app
Any thoughts?

@sindresorhus
Copy link
Owner

This is a problem with your Jest config, not this package.

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2023
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