facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.81k stars 26.87k forks source link

Getting error in Create React app Jest unit tests for import.meta syntax #13604

Open albert-kp opened 5 months ago

albert-kp commented 5 months ago

Discussed in https://github.com/facebook/create-react-app/discussions/13603

Originally posted by **albert-kp** June 3, 2024 Iam using **import.meta** syntax for calling a webworker url. This is causing issues with Jest unit tests. How to fix this issue any idea.? ``` const worker = new Worker(new URL('{worker_url}', import.meta.url)); ^^^^ SyntaxError: Cannot use 'import.meta' outside a module ```
Aa0558832337 commented 5 months ago

Discussed in #13603

Originally posted by albert-kp June 3, 2024 Iam using import.meta syntax for calling a webworker url. This is causing issues with Jest unit tests. How to fix this issue any idea.?

   const worker = new Worker(new URL('{worker_url}', import.meta.url));
                                                                                           ^^^^
    SyntaxError: Cannot use 'import.meta' outside a module
Aa0558832337 commented 5 months ago

/

Aa0558832337 commented 5 months ago

/

Aa0558832337 commented 5 months ago

13603