SWR and Jotai integration - swr

I want to use SWR and Jotai together and I have a problem with it!
Now I load SWR data in a custom hook and after that load them in Jotai atom with a useEffect!
Is there any solution to integrate SWR and Jotai?

Related

How to reuse test file in detox

I have an app where I am signing in and doing stuff. I want to reuse my signIn.e2e.js file. Basically I want to test dashboard, so I want to log in before that. Hence I want to use my signIn.e2e.js file in homeScreen.e2e.js file.
Any idea how I can do that?
I tried to do some research but haven't found anything. I am using jest test runner, it does have jest-runner-groups, but that's for jest, not for Detox.

Vue.js error when importing amChart data from web API

I'm learning Vue.js with amCharts and trying to build a covid-19 dashboard into a test project using data from amChart's own web API.
Hopefully, I don't need to put all my code on here because I'm just using amChart's demo code and I have the chart working from a module import within my own project, e.g.:
import covid_us_timeline from "#/assets/data/us_timeline";
That's module code I have copied from amChart's web API # covid.amcharts.com/data/js/us_timeline.js
So, that works great, but I want to use the chart directly from the web API, so I'm using this in my Vue.js script section:
import covid_us_timeline from "https://covid.amCharts.com/data/js/us_timeline.js";
And getting this error:
These dependencies were not found:
https://covid.amCharts.com/data/js/us_timeline.js in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/vuetify-loader/lib/loader.js??ref--18-0!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Covid19Chart.vue?vue&type=script&lang=js&
To install them, you can run: npm install --save https://covid.amCharts.com/data/js/us_timeline.js
Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys'
It doesn't look like a cors issue and given this is all public domain data, I'd rather use in the front-end than build it in the back-end, so any ideas what I'm doing wrong?
Just as an update, I decided to go a different way anyway as accessing this volume of data from the front-end was a drain to say the least. So, switched to using axios in Node to access the data and load into Mongo and then manipulate it from there. It was only updated once a day anyway, so no need to access it every time the page was loaded.

jest error: const warnedKeys: {[string]: boolean} = {};

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.

String functions not working in electron app

I have a .js file inside an electron app that uses the quasar framework.
inside this file i have axios to make requests to my api to pull data
once i get the response i use the data for further processing. However i need some string functions to escape some strings and when i try .replace it just fails.
var t = JSON.parse(JSON.stringify(someObj))
console.log(t.message.replace(/"/g, '\\"');)
the app just fails to build and tells me there is some error in x line. if i use console.log(t.message) i see that it print the text in the terminal console, so i know the value is not null.
Also when i hover my mouse over the variable it tells me (any) not sure what this means.
image:
P.S: this is my first time working this tech stack.
turned out there was a configuration issue with babel inside electron that was using quasar framework, it didn't not accept commonjs as module and hence no vanilla javascript would work.
Just had this issue myself, I know you've answered your own question but if you can use nodejs you can install replace-string from npm and use it
command: npm install replace-string
link:
https://www.npmjs.com/package/replace-string
This issue has literally caused me a morning of work - but hope someone finds this post and fixes this issue quicker!

Integration tests in golang - how to test the link between the router and the http.Handlers?

I've been tinkering around with golang and I try to implement a little todo application which should grow with the time. My thoughts about the applications architecture are the following:
The main package sets up the server and integrates the "services/handler" of the other packages in it's router under the corresponding path prefixes.
Every "service" has its own handlers and routes them correctly
So I've started just with the main package and wrote some todo handlers. To test the API I've written some integration tests (request/response). Now, I've removed the todo logic from the main package into it's own. When I execute go test -cover it shows me just the coverage of the main.go, but not for the todo package. That leads me to the conclusion that each package has to test on it's own.
So I have not to test the API in the main package but the integration, that '/todos' ends up in the todo package and nothing more, is that right? How can I test that? And in the todo package I have to test:
The routing in the package
And with a response recorder the API implementation
Is that right too? So how can I test the routing on it's own? Is that possible?
Here is my git repository:
https://github.com/fvosberg/mrsjenkins
Thanks in advance