I am struggling to get the correct way to mock appwrite sdk calls for testing my nodejs function. I use jest as test framework and want for example mock requests on the users sdk. I was thinking of something like this, but I am not sure if it is the right way to do...
jest.mock('../node_modules/node-appwrite/lib/services/users.js');
const client = new sdk.Client();
const users = new sdk.Users(client);
test("test_example", () => {
//Some testing code
users.list.mockResolvedValue(SOME_VALUE);
}
Is this the way to mock appwrite sdk calls?
Hi π I am not sure if we have some examples already about mock sdk calls, let me have a look
That would be great thank you !
Any luck yet finding something? π€©
Hmm not yet but - why do you need a mock? What might be better for you is to have a test that creates a plain new project, prepares it, and then run Appwrite Function on it. Check if function gave expected result, and destroy the project. All of that they can do on some kind of test server that you wound wipe every now and then to clear any left-overs.
Well thats true, using a project just for testing seems fair enough
Recommended threads
- Function executions via custom domain fr...
Aplogies if this was asked already. I'm self-hosting 1.9 on a self-hosted instance of Dokploy. I've made the necessary adjustments to the original compose file ...
- dynamic key missing scopes for database ...
Here are the scopes listed, I get permission errors for reading row and document. Appears to be missing since last time i checked. Database 6 Scopes policies....
- Worker functions stuck on "Fetched 0 fun...
Appwrite Version: 1.9.0 Bug Description: The appwrite-worker-functions container gets stuck in an infinite loop logging "Fetched 0 functions..." while scheduled...