error: Expression expected

See original GitHub issue

We are currently upgrading to NextJS 12, which is using SWC rather than babel.

I wanted to give @swc/jest a try because of ESM module issues with babel-jest:

SyntaxError: Cannot use import statement outside a module

After switching from '^.+\\.(js|jsx|ts|tsx)$': '<rootDir>/node_modules/babel-jest' to '^.+\\.(t|j)sx?$': '@swc/jest' I am getting the following errors:

FAIL  stories/stories.test.js
  ● Test suite failed to run

    error: Expression expected
      
       |
    36 |       <RouterContext.Provider value={mockRouter}>
       |       ^

    error: Expected ',', got 'value'
      
       |
    36 |       <RouterContext.Provider value={mockRouter}>
       |                               ^^^^^



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

Is @swc/jest not supposed to work with jsx/tsx files? The regrex implies that it does work with it. Any suggestions?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
maxhilliardcommented, Nov 26, 2021

Currently porting a test suite and had this issue. I had to set jsx / tsx to true to resolve this issue

[
  {
    "test": ".tsx?$",
    "jsc": {
      "parser": {
        "syntax": "typescript",
        "tsx": true
      },
      "target": "es5",
      "loose": false
    }
  },
  {
    "test": ".jsx?$",
    "jsc": {
      "parser": {
        "syntax": "ecmascript",
        "jsx": true,
        "decorators": false,
        "dynamicImport": false
      }
    }
  }
]
0reactions
kdy1commented, Nov 26, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Error:Expression expected - Stack Overflow
Error:Expression expected · 1. Change danielIntent. · 1. You can't use reserved keyword as an arguments. · 2. Sorry, it sounds bad and...
Read more >
Expression expected Error in TypeScript | bobbyhadz
The "Expression expected" TypeScript error occurs when we have a syntax error in our code or our code editor is using an older...
Read more >
Expression expected - Visual Basic - Microsoft Learn
An operator such as + or = requires an expression for its right operand, but no recognizable expression appears. Error ID: BC30201 ......
Read more >
Groovy syntax error "expression expected" : IDEA-196296
Using a Spock spec with a newline after == fails with "expected expression" (tested with Groovy 3.4.15 and Spock 1.1-groovy-2.4).
Read more >
Do you know why it appears "expression expected" error?
Do you know why it appears "expression expected" error? Do you know why appears an error "expression expected" in the code below? Copy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found