Amplify Gen2 documentation for testing setup (vitest)
Is your feature request related to a problem? Please describe. There is no clear example on how configure testing environment, if should us node or jsdom, if it is need runWithAmplifyContext...
Describe the solution you'd like An example of setup.ts file that provides auth, client, storage to be used in test framework like vitest
Describe alternatives you've considered some LLM instructions to share with AI agent and let it build the setup files. Also a direction on how to setup would be helpful, like emulating ssr context, or configure to use jsdom environment...
Additional context Vitest supports different environments ('node', 'jsdom', 'happy-dom'). When using standard library functions (not the one coming from 'aws-amplify/auth/server' or 'aws-amplify/api/server') the identiy is not availble in the resolver context.
{
"logType": "RequestFunctionEvaluation",
"path": [
"getMyProfile"
],
"fieldName": "getMyProfile",
"resolverArn": "..."
"functionName": "Fn_Query_getMyProfile_1",
"requestId": "1c8bb2e0-1ebf-4a19-b391-5298585a9f16",
"context": {
"arguments": {},
"prev": {
"result": {}
},
"stash": {
"amplifyApiEnvironmentName": "NONE",
"awsAppsyncApiId": "...."
},
"outErrors": []
},
"fieldInError": true,
"errors": [
"Not Authorized to access getMyProfile on type Query"
],
"parentType": "Query",
....
}
Using the others and runWithAmplifyContext is not so clear (no cookies in test environment)
Hi @sot1986 ,
Thank you for creating this ticket! We love hearing ideas from the community on how to improve our docs. We will review it with the team and get back to you once we have an update.