6

I am writing first tests for my app and just install Jest.

My test is pretty simple, so I don't think the error I am getting is coming from there.

import React from 'react';
import renderer from 'react-test-renderer';
import FancyInput from './FancyInput';

describe('FancyInput', () => {
  it('should render correctly', () => {
    expect(
      renderer.create(
        <FancyInput />
      )
    ).toMatchSnapshot();
  });
});

Error when run the test is Support for the experimental syntax 'jsx' isn't currently enabled also

`Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
    If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.`

enter image description here My webpack file has the following thing:

rules: [
  {
    test: /\.js$/,
    exclude: /node_modules/,
    use: {
      loader: 'babel-loader',
      options: {
        presets: [
          '@babel/preset-react',
        ],
        plugins: [
          ["@babel/plugin-proposal-decorators", { "legacy": true }],
          ["@babel/plugin-proposal-optional-chaining"],
          ["@babel/plugin-syntax-jsx"],
        ]
      }
    }
  },

also my package.json has all the plugins I believe are necessary

"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-decorators": "^7.4.4",
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
"@babel/plugin-syntax-jsx": "^7.10.4",
"@babel/preset-react": "^7.0.0",

what am I missing here ?

vbotio
  • 1,566
  • 3
  • 26
  • 53

0 Answers0