He people, I am struggling a lot with this error today as I need to set up my environment to start Testing my components using Jest and Testing Library This is my error and I tried a lot of things but it doesn't seem to work.
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import React from 'react';
^^^^^^
SyntaxError: Cannot use import statement outside a module
This is package.json
"scripts": { "test": "jest", } "devDependencies": { "@babel/plugin-syntax-jsx": "^7.12.1", "@babel/preset-react": "^7.12.5", "@testing-library/jest-dom": "^5.11.5", "@testing-library/react": "^11.1.1",
This is my webpack.config.js
module: {
rules: [
{
test: /\.(js|jsx)?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-2']
}
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
querystring: 'querystring-browser'
}
},
Also is there anything needs to be done to yarn.lock file?? As I just found out it. I will appreciate any help.
Aucun commentaire:
Enregistrer un commentaire