I am facing this issue. after running my unit test. This same error occurs wherever the static variable present. do you have any solution for this? or what causing this issue
similarly, the same error showing for the auto binding too.
ex:
handle = ()=>{
}
finally, I found the solution.
add this below lines in the babelrc file
"presets": ["env", "react"],
"plugins": ["transform-class-properties"]
And also if someone facing below issue, Kindly check your node version. it should be 8+ version. Because I faced this issue.
...this.state is undefined
^^^
Related
I have troubles with debugging my jest tests. Maybe I introduce my setup first:
root-dir
test
sample.spec.ts
jest.config.js
package.json
tsconfig.json
The contents of sample.spec.ts:
describe('Sample', () => {
it.concurrent('App', async () => {
expect(true).toEqual(true); // here the breakpoint is set
});
});
So nothing fancy to be debugged here. I installed the Jest Runner extension in VS Code.
However, when I "click" the "Debug" button, right above the it, the debugger starts, but shows an exception:
Exception has occurred: Error: Cannot find module 'jest-environment-<path-to-my-root-dir>\node_modules\jest-environment-node\build\index.js/package.json' from '<path-to-my-root-dir>'e
What is the problem there? In the node_modules directory, the jest-environment-node is there. The path form the exception is not correct, hence it can't find the package.json. But this one I can't influence!
I appreciate your help!
Kind regards to all of you!
I've found the solution to this problem... which isn't a problem at all. It is also answered here: Cannot find module jest-sequencer-#jest/test-sequencer!
So... never ever tick Caught Exceptions and Uncaught Exceptions in VS Code:
Without those two ticks, jest works out of the box.
Here's the error I'm getting inside of my application:
Uncaught ReferenceError: module is not defined
at isHotReloading2 (isHotReloading.js:2:20)
at Form3.UNSAFE_componentWillMount (createReduxForm.js:511:16)
and here's what the error looks like in the chrome inspector:
I can't easily change the course code of redux-form (which is no longer being maintained) and neither can I remove it from my application. Is there a way to work around this error?
I've tried the following fixes in the vite.config.js file to no avail. Any ideas would be greatly appreciated. Thanks!
I ran into this same issue with Redux-form and fixed it as follows.
Create a file with the following
const isHotReloading = () => false;
export default isHotReloading;
In your vite.config file add the following to resolve.alias
{
find: './util/isHotReloading',
replacement: path.resolve(__dirname, './PATH_TO_FILE_ABOVE/reduxFormHotReload.js'),
},
This will disable the hot reload update functionality all together, so maybe you could improve the function above, but I didn't worry about it.
Why does vue still report jsx errors? Although an error is reported, it can be executed normally. What is the reason?
<el-submenu index="1">
< const ElMenuItem: unknown
JSx element type 'E1MenuItem' does not have any construct signature or call signature. ts (2604)>
< View issues No quick fixes available>
< el-menu-item index="1-1">item1</el-menu-item>
< el-menu-item index="1-2">item1</el-menu-item>
</el-submenu>
It should be a problem with the volar plugin. Try to upgrade the version of the plugin to 0.36.1, or you can add some configuration and add such a configuration to tsconfig.json.
{
"vueCompilerOptions": {
"experimentalSuppressInvalidJsxElementTypeErrors": true
}
}
I'm getting an error from one of my (previously working) tests when I run yarn jest:
Cannot find module 'got' from 'src/rss/queries.ts'
I've added got in package.json:
"devDependencies": {
"got": "^12.0.0",
}
My jest.config.js:
module.exports = {
preset: 'ts-jest',
testMatch: ['**/*.test.ts(|x)'],
collectCoverageFrom: ['**/*.ts', '!.webpack/**/*'],
verbose: true,
}
I'm using got in ./src/rss/queries.ts:
import * as got from 'got'
I've also tried:
import { got, RequestError } from 'got'
In both cases the application works - I can see got making requests via the application logs (and vscode is indicating the correct path to the module in node_modules when I hover over the above). So it's definitely there, and working.
But jest can't find it. Why? It's not an uncommon stackoverflow question, but they all seem to relate to importing custom local modules via relative paths, etc. I'm just trying to use one out of node_modules...
Version 12 of got doesn't work with jest. Best to use version 11 for now. See the details in the release notes at: https://github.com/sindresorhus/got/releases/tag/v12.0.0
Wasn't able to find a reason for, or solution to, this. Ended up swapping got for axios, which is a shame as I liked many got features.
We're using async/await for our Meteor project. This syntax is everywhere in our resolvers.js. Everything has been working fine until we've upgraded to Node 6.7. Now it shows this error every time we try to build it:
"The keyword 'await' is reserved (53:24)"
Does anyone know how to solve this?
Here is the content of my .babelrc file:
{
"presets": ["es2015", "stage-2", "react"],
"plugins": ["react-require", "babel-root-slash-import"]
}
Just in case anyone else searches for this same issue, in my case it was user error, me. I forgot to put the async keyword before the function name.
Okay, I found out a solution to my own problem. I just excluded the .babelrc when doing a Meteor build since Meteor already has a package that supports ES6 syntax. I didn't totally remove the .babelrc because I will be needing it on tests and when running the Storybook which does not trigger a Meteor build.
Await alone is invalid syntax. await needs to be called inside an async function like:
var aFunction = async function() {
let aResponse = await get('aValue');
}