tdm-calculator icon indicating copy to clipboard operation
tdm-calculator copied to clipboard

Fix Feedback Page jest tests

Open nclairesays opened this issue 3 years ago • 12 comments

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.

nclairesays avatar Dec 03 '20 02:12 nclairesays

Working to hopefully have this done by next meeting

nclairesays avatar Dec 10 '20 04:12 nclairesays

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.

nclairesays avatar Dec 17 '20 03:12 nclairesays

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.

fyliu avatar Sep 22 '21 23:09 fyliu

@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

fyliu avatar Sep 23 '21 22:09 fyliu

@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.

fyliu avatar Sep 24 '21 03:09 fyliu