Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hapi + jest / how testing update user? #4390

Open
robokonk opened this issue Nov 12, 2022 · 0 comments
Open

hapi + jest / how testing update user? #4390

robokonk opened this issue Nov 12, 2022 · 0 comments
Labels
support Questions, discussions, and general support

Comments

@robokonk
Copy link

I have problem with one test:

test('update user', async () => {
  const updatedFirstName = 'test-first-name-UPDATED'
  const updatedLastName = 'test-last-name-UPDATED'

  const response = await server.inject({
    method: 'PUT',
    url: `/users/${userId}`,
    payload: {
      firstName: updatedFirstName,
      lastName: updatedLastName,
    },
  })
  expect(response.statusCode).toEqual(200)
  const user = JSON.parse(response.payload)
  expect(user.firstName).toEqual(updatedFirstName)
  expect(user.lastName).toEqual(updatedLastName)
})

I get:
expect(received).toEqual(expected) // deep equality Expected: 200 / Received: 500.

Bellow full code:

https://pastebin.com/i8JjbkeE
https://pastebin.com/cTshA0PW

What is wrong with this test?
My database is empty ofc.

@robokonk robokonk added the support Questions, discussions, and general support label Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

1 participant