fullstack-hy2020 / fullstack-hy2020.github.io

https://fullstack-hy2020.github.io
Other
1.48k stars 3.69k forks source link

Part 4b skips change in code in beforeEach function. #3660

Open fecfecfec opened 1 month ago

fecfecfec commented 1 month ago

I reached the section 'Refactoring tests' and found that beforeEach is declared as:

beforeEach(async () => {
    await Note.deleteMany({})
    await Note.insertMany(helper.initialNotes)
  })

But in the last stage and last linked branch (Part 4-5) before that section, beforeEach was declared as:

beforeEach(async () => {
  await Note.deleteMany({})

  const noteObjects = helper.initialNotes
    .map(note => new Note(note))
  const promiseArray = noteObjects.map(note => note.save())
  await Promise.all(promiseArray)
})

I would suggest a change in the content in the section Optimizing the beforeEach function, but I don't know the explanation besides "this looks cleaner".

Both solution work (or at least the test are running fine).

imlakshaychauhan commented 3 weeks ago

Hi @fecfecfec,

Could I please be assigned to this issue? I noticed it hasn't been closed yet and I'd love to help resolve it.

Thank you!

fecfecfec commented 3 weeks ago

Hi @imlakshaychauhan , I think @mluukkai has the permission to assign the issue.