fullstack-hy2020 / fullstack-hy2020.github.io

Home Page:https://fullstack-hy2020.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

part 4b standalone expect function

carlireul opened this issue · comments

under the subheading 'more tests and refactoring the backend', one of the code snippets uses a standalone expect function which will return an error 'expect is not defined'. it appears supertest does not have a standalone expect function. using assert like the other tests solves the issue.

// ...
test('all notes are returned', async () => {
  const response = await api.get('/api/notes')

  expect(response.body).toHaveLength(helper.initialNotes.length)
})

test('a specific note is within the returned notes', async () => {
  const response = await api.get('/api/notes')

  const contents = response.body.map(r => r.content)

  expect(contents).toContain(
    'Browser can execute only JavaScript'
  )
})