How to use the @loopback/testlab.createClientForHandler function in @loopback/testlab

To help you get started, we’ve selected a few @loopback/testlab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strongloop / loopback-next / examples / log-extension / src / __tests__ / acceptance / log.extension.acceptance.ts View on Github external
it('logs information at INFO or higher', async () => {
    setAppLogToInfo();
    const client: Client = createClientForHandler(app.requestHandler);

    await client.get('/nolog').expect(200, 'nolog called');
    expect(spy.called).to.be.False();

    await client.get('/off').expect(200, 'off called');
    expect(spy.called).to.be.False();

    await client.get('/debug').expect(200, 'debug called');
    expect(spy.called).to.be.False();

    await client.get('/info').expect(200, 'info called');
    sinon.assert.calledWith(spy, infoMatch);

    await client.get('/warn').expect(200, 'warn called');
    sinon.assert.calledWith(spy, warnMatch);
github strongloop / loopback-next / packages / rest / src / __tests__ / integration / rest.server.integration.ts View on Github external
it('allows cors preflight', async () => {
    const server = await givenAServer();
    server.handler(dummyRequestHandler);

    await createClientForHandler(server.requestHandler)
      .options('/')
      .expect(204)
      .expect('Access-Control-Allow-Origin', '*')
      .expect('Access-Control-Allow-Credentials', 'true')
      .expect('Access-Control-Max-Age', '86400');
  });
github strongloop / loopback-next / packages / rest / src / __tests__ / integration / rest.server.integration.ts View on Github external
it('can add openApiSpec endpoints before express initialization', async () => {
    const server = await givenAServer();
    server.addOpenApiSpecEndpoint('/custom-openapi.json', {
      version: '3.0.0',
      format: 'json',
    });

    const test = createClientForHandler(server.requestHandler);
    await test.get('/custom-openapi.json').expect(200);
  });
github strongloop / loopback-next / packages / authentication / src / __tests__ / acceptance / jwt-auth-extension.acceptance.ts View on Github external
function whenIMakeRequestTo(restServer: RestServer): Client {
    return createClientForHandler(restServer.requestHandler);
  }
});
github strongloop / loopback-next / packages / rest / src / __tests__ / acceptance / sequence / sequence.acceptance.ts View on Github external
function whenIRequest(restServerOrApp: HttpServerLike = server): Client {
    return createClientForHandler(restServerOrApp.requestHandler);
  }
});
github strongloop / loopback-next / labs / authentication-passport / src / __tests__ / acceptance / authentication-with-passport-strategy-adapter.acceptance.ts View on Github external
function whenIMakeRequestTo(restServer: RestServer): Client {
    return createClientForHandler(restServer.requestHandler);
  }
});
github strongloop / loopback-next / packages / authentication / src / __tests__ / acceptance / basic-auth.acceptance.ts View on Github external
function whenIMakeRequestTo(restServer: RestServer): Client {
    return createClientForHandler(restServer.requestHandler);
  }
});