Skip to content

What is the best way to write controller tests? #188

@createthis

Description

@createthis

I apologize if this is obvious, but I'm having trouble figuring it out.

What is the best way to write controller tests for an end point protected by hapi-auth-cookie?

I'm doing something like this in my controller test:

      let response = await server.inject(request);
      should.equal(response.statusCode, 200);

However, request.url is protected by hapi-auth-cookie, so I get a 302 redirect code because it (correctly) wants me to log in.

What's the best way to fake a login so server.inject works as expected?

Metadata

Metadata

Assignees

Labels

supportQuestions, discussions, and general support

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions