0

i am trying to implement testing using @hapi/lab and @hapi/code . I am struct on how can i provide query parameter in order to test as there is no option to pass it in Options. In my API, i have 2 parameter to pass, 1) JWT token which is authorization and 2) query { "name": "string" } please guide me how can i enter query parameter and then check according to it. This is my test case i created.

describe('Routes', () => {
  let server;
  let response;

  describe('with JWT token /dashboard', () => {
    beforeEach(async () => {
      server = await init();
    });

    it('it returns a 200', async () => {
      const authorization = await authenticate(server);
      const Options = {
        method: 'GET',
        url: '/dashboard',
        headers: {
          authorization,
        },
      };
      response = await server.inject(Options);
      expect(response.statusCode).to.equal(200);
    });
  });

1 Answers1

0

In the

server.inject({url:'/xyz?id='+term})

and declare

const term = 'abc';

inside it block and this pass query parameter check