I'm receiving the following error when I try to run a Jest snapshot test on my react-native code
should I create a mock for Relay? is there any code example of mocking Relay to work with jest and react-native?
Error: Cannot find module 'react-dom' from 'relayUnstableBatchedUpdates.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:151:17)
at Object.<anonymous> (node_modules/react-relay/lib/relayUnstableBatchedUpdates.js:15:18)
at new RelayEnvironment (node_modules/react-relay/lib/RelayEnvironment.js:39:63)
Related
I have a Nuxt project. I've installed Buefy via the steps outlined in the docs. That is:
Run npm i nuxt-buefy
Add 'nuxt-buefy' to modules in nuxt.config.js
I then run the dev server via
npm run dev
...and I get this gumf below. Thing is, Buefy doesn't say anything about having to first add postcss-custom-properties. What am I doing wrong?
ERROR Cannot find module 'postcss-custom-properties' 18:54:24
Require stack:
- C:\Users\mitya\Sync\dev\projects\rpar\node_modules\#nuxt\core\dist\core.js
Require stack:
- node_modules\#nuxt\core\dist\core.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.resolve (internal/modules/cjs/helpers.js:94:19)
at m (node_modules\jiti\dist\jiti.js:1:52953)
at Resolver.f [as _require] (node_modules\jiti\dist\jiti.js:1:53766)
at Resolver.requireModule (node_modules\#nuxt\core\dist\core.js:381:29)
at node_modules\#nuxt\webpack\dist\webpack.js:603:58
at Array.map (<anonymous>)
at PostcssConfig$1.loadPlugins (node_modules\#nuxt\webpack\dist\webpack.js:602:10)
at PostcssConfig$1.config (node_modules\#nuxt\webpack\dist\webpack.js:638:14)
at StyleLoader.postcss (node_modules\#nuxt\webpack\dist\webpack.js:909:39)
at StyleLoader.apply (node_modules\#nuxt\webpack\dist\webpack.js:969:12)
at WebpackClientConfig.rules (node_modules\#nuxt\webpack\dist\webpack.js:1357:28)
At the end, scaffolding a brand new Nuxt project was still the easiest to setup Buefy.
Probably that comparing both a new project and an old one and transferring the configuration is the way to go.
If I run yarn test, which runs jest, I get the following error:
C:\react-native-project\node_modules\react-native\Libraries\Utilities\warnOnce.js:15
const warnedKeys: {[string]: boolean} = {};
But that only happens if I follow the directions of the react-native-testing-library:
Then automatically to add it to your jest tests by using setupFilesAfterEnv option in the
jest.config.js file:
If I remove the file I will not get that error and I can get simple tests to run. When I remove the file, the test runs but AsyncStorage is not recognized so the tests still don't run. I have AsyncStorage. It's installed and the app works, but I want to add component tests. I also noticed the file, jest.config.js, is conspicuously missing from the testing project itself. Is there any documentation or working example? I would rather not do a diff of my project and the testing project. Is there a more well-documented or reliable testing framework/module available?
I'm able to get working tests by following the documentation of the React Native Testing Library with the npm package name of #testing-library/react-native not to be confused with the React Native Testing Library with the npm package name of react-native-testing-library. Both packages allow testing components and are recommended by React-Native documentation but this one works when following the instructions. It also has instructions "to define a custom render method that includes things like global context providers, data stores, etc" so that testing components with AsyncStorage and such shouldn't be a problem.
Trying to import #nimiq/core or #nimiq/core-web or https://cdn.nimiq.com/nimiq.js to my Nativescript app but I can't found the way.
I've already tried with nativescript-nodeify but it thows and error in nativescript-vue (which I'm using)
Error is: Cannot find module '[...]\platforms\android\app\src\main\assets\app\tns_modules\nativescript-nodeify\patch-npm-packages.js'.
I'm using react 16.6.3, react-flexbox-grid 2.1.2 and webpack version 4.25.1 and for test cases jest 23.6 and enzyme. While running my tests I get the following error:
/home/sanju/Quizetencyplayground/quizetencyplatform/webapp/node_modules/flexboxgrid2/flexboxgrid2.css:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){.container {
^
SyntaxError: Unexpected token .
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
at Object.<anonymous> (node_modules/react-flexbox-grid/lib/classNames.js:8:20)
can anyone tell me solution why it is how to remove this
It looks like Webpack doesn't know how to handle CSS files.
You probably have to add a CSS loader like this one.
If it is an option for you I would suggest to use create-react-app so you don't have to configure Webpack.
In my react native cli project I am having trouble importing local files.
I just created the project using cli and it was working fine. I ran it in my mobile and it showed the default welcome message. Then I made src folder, components folder in it and created a Header component.
As soon as I imported the header component in App.js and used it it showed this errror message in my packager console.
Bundling `index.js` [development, non-minified] 0.0% (0/317),failed.
error: bundling failed: UnableToResolveError: Unable to resolve module `./src/components/Header` from `/home/sagar/workspace/native/my_expences/App.js`: could not resolve `/home/sagar/workspace/native/my_expences/src/components/Header' as a file nor as a folder
at ModuleResolver._loadAsFileOrDirOrThrow (/home/sagar/workspace/native/my_expences/node_modules/metro-bundler/src/node-haste/DependencyGraph/ModuleResolution.js:337:11)
at ModuleResolver._resolveFileOrDir (/home/sagar/workspace/native/my_expences/node_modules/metro-bundler/src/node-haste/DependencyGraph/ModuleResolution.js:222:17)
at ModuleResolver.resolveNodeDependency (/home/sagar/workspace/native/my_expences/node_modules/metro-bundler/src/node-haste/DependencyGraph/ModuleResolution.js:236:19)
at ResolutionRequest.resolveDependency (/home/sagar/workspace/native/my_expences/node_modules/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js:111:14)
at dependencyNames.map.name (/home/sagar/workspace/native/my_expences/node_modules/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js:136:10)
at Array.map (<anonymous>)
at ResolutionRequest.resolveModuleDependencies (/home/sagar/workspace/native/my_expences/node_modules/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js:135:42)
at Promise.resolve.then (/home/sagar/workspace/native/my_expences/node_modules/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js:175:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
The error goes away if I remove the Header component and the import statement.
Please help
Edit:
It turns out it is having trouble importing file with jsx extension. I changed the extension to js and the error went away.
So, How can I import jsx files.