fullstack-hy2020 / fullstack-hy2020.github.io

https://fullstack-hy2020.github.io
Other
1.56k stars 4k forks source link

fix(test): `.forEach` expects a synchronous function #3601

Closed ricky-kiva closed 6 months ago

ricky-kiva commented 6 months ago

Some tests related to database operation over API could fail erratically. In my case, a specific note can be viewed test failed. This happened because .forEach expects a synchronous function.

Reference: https://betterprogramming.pub/javascript-async-await-pitfalls-with-foreach-d55dddc42d0

ricky-kiva commented 6 months ago

Turns out, it's already explained that .forEach won't work within beforeEach() in the later part.