tdm-calculator
tdm-calculator copied to clipboard
Fix Feedback Page jest tests
Fix breaking Public Comment jest tests so that tests can run in CI pipeline
- [x] Rename all code and db objects from Public Comment to Feedback, including the client-side routing path to /feedback
- [x] rename and move postPublicComment.js to /src/services/feedback-service.js
- [x] rename PublicCommentPage.js to FeeddbackPage.js
- [x] remove postPublicComment.test.js - I don't think the test has value.
- [x] rename PublicCommentPage.test.js to FeedbackPage.test.js
- [x] debug FeedbackPage.test.js to get tests working.
Working to hopefully have this done by next meeting
Spent some time trying to fix the frontend tests but am unable to get it to pass properly even though I am using patterns I know "should" work. I think that the errors are due to library version compatibility but have not validated this.
Next person who picks up this issue, look into versions for the following libraries: jest, react, react-dom, react-testing-library, and maybe nock if we want to use nock. There are ways to test api calls without using nock.
I wasn't able to spend much time on this. I will do more this week.
I'm able to run the simplest nock+axios test https://www.npmjs.com/package/nock#axios I'm thinking of using the nock recorder feature to figure out if our expected request is correct.
@nclairesays I only fixed the existing tests in the file. It can be possibly expanded to record the real responses to the requests and then testing against them.
I also read that msw mocks works for both the server and client at the same time, so that might be worth looking into just to save developer time. https://github.com/mswjs/msw
@nclairesays I might just leave this alone for now. I tried a while ago to test something with that toast provider context and wasn't able get it working.