Open cjsilva-umich opened 1 year ago
Hey @cjsilva-umich :wave: thanks for raising this! I'm going to transfer this over to our Hosting repo for better assistance 🙂
Any chance that someone might be able to comment on this?
Hi @cjsilva-umich 👋🏽 apologies for the delay here. It's difficult to determine next steps without knowing how you configured your script to access the appropriate database. Is there any example code you could share to help us identify why your live data is being accessed?
Hi @hloriana,
I don't have any additional files that configure anything to do with the mocking or the db targeting (not intentionally anyway). Do you have any suggestions about where I might look to find anything targeting the like? The only things I've put in place to try to get this working is the amplify.yml file and the startMockApi.sh file, both shown in their entirety above.
From what I can tell, Amazon doesn't have any official documentation for how to set up db mocking for the Test phase in Amplify's build and deploy process, that's why I followed the suggestions of others in the thread I linked to in my original post.
Are you able to use amplify mock api
in conjunction with Cypress testing wherein a mocked database is used during the cypress tests and then the live database is targeted once more (unmodified from tests) when tests are finished and the project is deployed live again? If you are, could you please share your configuration of your amplify.yml file and, even some examples that show the live database isn't modified and that the mocked one is used during tests? It would help IMMENSELY.
Thank you!
Anyone having any success using amplify mock api
in the Test phase of the Amplify build process?
Can anyone get back to me about this?
I have a similar issue, I have a monorepo with Nx and three projects with NextJS, I need the three of them running to have a proper e2e test, but just one monorepo can get the mock awsconfig.js and the other projects keeps the awsconfig config that aims to the real db.
Can anyone from amazon/aws please confirm for me whether or not they are able to use 'amplify mock api' in the test phase of the Amplify build and have it not modify the live database. And, if so, how they are able to do so? Been waiting a long time for help with this.
Amplify CLI Version
10.4.1
Question
Using the suggestions in this thread, I have configured my amplify.yml file to run 'amplify mock api' and run my cypress tests during the build phase of my amplify project. Part of the cypress tests involves clearing out the database and providing initial seed data.
This works exactly like I expect it to locally on my machine. 'amplify mock api' creates a local database and, if there's any existing data in it from a previous run, it clears it all out before creating the initial data needed to run the app. Then, when I'm done with my tests, I ctrl-c my process to stop mocking the api, my app targets the remote data, and it's all as it was before my tests.
However, now that I've got the tests running as part of the build phase, the clearing/seeding process is happening to my live data. Thankfully I'm just doing this all on a personal development branch, but if it had happened on a production environment it could have been disastrous.
What is happening in the build process that is not targeting the locally created/mocked database? How can I get this to behave like I want where the automated cypress runs in the test phase are not using my live data?
Here is my amplify.yml file contents (nearly identical to those from the linked issue):
and startMockApi.sh: