Cannot test for cookies

I need to test that a cookie is set once a user signs up by filling a sign up form.

I was using HTTP tests since the Browser tests cannot assert cookies.

This is my code below:-

test('sets cookie on registration', async ({ client }) => {
  const response = await client
    .post('register')
    .session('quciksession', 1)
    .send({
      username: 'username,
      email: 'mail@email.com',
      password: 'password
    })
    .end()


  response.assertPlainCookie('test', 'test')
}).timeout(5000)

This always returns InvalidSessionException: E_INVALID_SESSION: Invalid session.

I disable CSRF for testing too.

Any ideas how to test for this case?

1 Like