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

JSX syntax extension is not currently enabled for Jest runner #58

Open
AndiLavera opened this issue Apr 22, 2022 · 1 comment
Open

JSX syntax extension is not currently enabled for Jest runner #58

AndiLavera opened this issue Apr 22, 2022 · 1 comment

Comments

@AndiLavera
Copy link

Problem

It seems like the loader I defined in my config is not being passed to Esbuild.

esbuild-runner.config.js

module.exports = {
  debug: true,
  esbuild: {
    loader: { '.js': 'jsx' },
    target: 'esnext',
  },
  type: 'transform', // I also tried bundle
};

Note: Dropped a console.log in this file, it is being loaded.

Jest config

{
  "transform": {
    "^.+\\.(js|jsx|ts|tsx)$": "esbuild-runner/jest"
  }
}

Error Message

yarn run v1.22.17
$ jest spec/javascript/components/Accordion.test.js

 RUNS  spec/javascript/components/Accordion.test.js
✘ [ERROR] The JSX syntax extension is not currently enabled

    /workspace/spec/javascript/components/Accordion.test.js:11:6:
      11 │       <Accordion expanded={false}>
         ╵       ^

  The esbuild loader for this file is currently set to "js" but it must be set to "jsx" to
 FAIL  spec/javascript/components/Accordion.test.js { '.js': 'jsx' }" to do that.
  ● Test suite failed to run

    Transform failed with 1 error:
    /workspace/spec/javascript/components/Accordion.test.js:11:6: ERROR: The JSX syntax extension is not currently enabled

      at failureErrorWithLog (node_modules/esbuild/lib/main.js:1603:15)
      at node_modules/esbuild/lib/main.js:1392:29
      at node_modules/esbuild/lib/main.js:666:9
      at handleIncomingPacket (node_modules/esbuild/lib/main.js:763:9)
      at Socket.readFromStdout (node_modules/esbuild/lib/main.js:632:7)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.228 s
Ran all test suites matching /spec\/javascript\/components\/Accordion.test.js/i.
error Command failed with exit code 1.
@eliseumds
Copy link

Same here. Running jest with --no-cache.

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