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

Test suite failed to run error: Expected ';', '}' or <eof> #83

Open
Brysonmk1984 opened this issue Mar 10, 2022 · 1 comment
Open

Test suite failed to run error: Expected ';', '}' or <eof> #83

Brysonmk1984 opened this issue Mar 10, 2022 · 1 comment

Comments

@Brysonmk1984
Copy link

I just tried switching to this package instead of ts-jest since it was so slow at handling errors. I get this error on any test I run... I'm assuming I didn't configure this properly. Any ideas? Do I need to set up a .swcrc file? if so, what goes in there?

Thanks for your work on this.

@therynamo
Copy link

therynamo commented Mar 11, 2022

Do I need to set up a .swcrc file?

Yes - that or inline it like the README implicitly suggests: https://github.com/swc-project/jest#usage

module.exports = {
  transform: {
    '^.+\\.(t|j)sx?$': ['@swc/jest', { ...config, /* custom configuration in Jest */ }], //.swcrc contents go here in place of `config`
  },
}

I am also here because of the recent ts-jest issues kulshekhar/ts-jest#1967 (Granted it could be Jest it could be v8. Ultimately - I just wanted to move to SWC to get faster, more stable, and ultimately most performant tests I can run).

I am trying to use this package with a React Native app - and am running into issues after I resolve the one listed here. I resolved this issue you've outlined by adding an .swcrc. I have tried a couple of different .swcrc configurations:

And just a basic one from the example in the repo here:

"@swc/jest",
{
"sourceMaps": true,
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true
},
"transform": {
"react": {
"runtime": "automatic"
}
}
}
}
]
},

The above works without a physical .swcrc file - which is what I'll opt for since our App wont be built using SWC yet (or maybe ever 🤷 Depends on the RN support in the future.)

The issue I'm running into now - is very similar:

 FAIL  MyApp/x/y/z.spec.tsx
  ● Test suite failed to run

    error: Expected ',', got ':'

       |
    51 |   applyWithGuard<TArgs: $ReadOnlyArray<mixed>, TOut>(
       |                       ^



    Caused by:
        0: failed to process js file
        1: Syntax Error

      at Compiler.transformSync (node_modules/@swc/core/index.js:137:25)
      at transformSync (node_modules/@swc/core/index.js:217:21)
      at Object.process (node_modules/@swc/jest/index.js:55:45)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:612:31)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:758:40)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:815:19)

I haven't had any luck getting past this point and would LOVE some help troubleshooting how to move forward.

EDIT: I'll make a separate issue so this question doesn't muddy up your question. Hope this answer helped though. #85

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

No branches or pull requests

2 participants