dcsil / dream-team

Team repository for Dream Team
https://dreamtune-cdf8a.web.app/auth/login
0 stars 1 forks source link

Fix NPM tests in Service.yml from spinning forever #167

Closed RyanMarten closed 4 years ago

RyanMarten commented 4 years ago

Using links in #165 about mocking

RyanMarten commented 4 years ago

Can also look at this other Github actions Cache from the market place: https://github.com/marketplace/actions/cache works on Yarn too

RyanMarten commented 4 years ago

From the Github Actions workflow:

Ran all test suites.
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
##[error]The operation was canceled.
RyanMarten commented 4 years ago

I guess this means I should take the asynchronous calls out of Map.js and Firestore.js and mock them instead

RyanMarten commented 4 years ago

https://jestjs.io/docs/en/mock-functions.html#mocking-modules

This is confusing and difficult, but I think this is the resource I am going to focus on.

RyanMarten commented 4 years ago

It is just not working: let's try google again: https://medium.com/@jamomani/mocking-firebase-cloud-functions-in-react-js-with-jest-d5596d25da2

RyanMarten commented 4 years ago

Ok let's try specifically how people Jest Mock Firestore, not only just firebase: https://stackoverflow.com/questions/52043886/how-do-you-mock-firebase-firestore-methods-using-jest https://medium.com/stories-from-upstatement/jest-mocks-roasting-on-an-open-firestore-36fa55b76953 https://stackoverflow.com/questions/52043886/how-do-you-mock-firebase-firestore-methods-using-jest

RyanMarten commented 4 years ago

Alright this is pretty complex so I am going to use this library: https://medium.com/stories-from-upstatement/jest-mocks-roasting-on-an-open-firestore-36fa55b76953

https://github.com/Upstatement/firestore-jest-mock

npm install --save-dev firestore-jest-mock

RyanMarten commented 4 years ago

^^ THAT WORKS SO WELL :))))))