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

SyntaxError in Node v18.16.0 when using Jest #9

Open
MaddyGuthridge opened this issue Jul 26, 2023 · 0 comments
Open

SyntaxError in Node v18.16.0 when using Jest #9

MaddyGuthridge opened this issue Jul 26, 2023 · 0 comments

Comments

@MaddyGuthridge
Copy link

MaddyGuthridge commented Jul 26, 2023

Hello!

I'm investigating this library's feasibility for a course I tutor, as a less problematic (and hopefully faster) alternative to sync-request.

However, in my test repository, the import appears to fail.

    /home/migue/Source/COMP/1531/best-test-request/node_modules/await-sync/mod.js:4
    const Work = globalThis.Worker || await import('whatwg-worker').then(m => m.default)
                                      ^^^^^

    SyntaxError: await is only valid in async functions and the top level bodies of modules

      2 | import inject from 'light-my-request';
      3 | import server from '../express_app/server';
    > 4 | import { createWorker } from 'await-sync';
        | ^
      5 |
      6 | const awaitSync = createWorker();
      7 |

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1495:14)
      at Object.require (tests/server.test.js:4:1)

You can see the code I'm using by visiting this file in my testing repository.

Perhaps the library is having an issue with Jest's runtime? How should I get it to work correctly?

@MaddyGuthridge MaddyGuthridge changed the title SyntaxError in Node v18.16.0 SyntaxError in Node v18.16.0 when using Jest Jul 26, 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

1 participant