How to use the @loopback/testlab.givenHttpServerConfig 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 / todo-list / src / __tests__ / acceptance / todo-list-todo.acceptance.ts View on Github external
async function givenRunningApplicationWithCustomConfiguration() {
    app = new TodoListApplication({
      rest: givenHttpServerConfig(),
    });

    await app.boot();

    /**
     * Override default config for DataSource for testing so we don't write
     * test data to file when using the memory connector.
     */
    app.bind('datasources.config.db').to({
      name: 'db',
      connector: 'memory',
    });

    // Start Application
    await app.start();
  }
github iqbaldjulfri / lb4-jwt-role-based-auth-sample / src / __tests__ / acceptance / test-helper.ts View on Github external
export async function setupApplication(): Promise {
  const restConfig = givenHttpServerConfig({
    // Customize the server configuration here.
    // Empty values (undefined, '') will be ignored by the helper.
    //
    // host: process.env.HOST,
    // port: +process.env.PORT,
  });

  const app = new Lb4JwtRoleBasedAuthSampleApplication({
    rest: restConfig,
  });

  await app.boot();
  await app.start();

  const client = createRestAppClient(app);
github strongloop / loopback-next / packages / http-server / src / __tests__ / integration / http-server.integration.ts View on Github external
it('starts server', async () => {
    const serverOptions = givenHttpServerConfig();
    server = new HttpServer(dummyRequestHandler, serverOptions);
    await server.start();
    await supertest(server.url)
      .get('/')
      .expect(200);
  });
github strongloop / loopback-next / packages / rest / src / __tests__ / integration / rest.server.integration.ts View on Github external
it('supports HTTPS protocol with key and certificate files', async () => {
    const keyPath = path.join(FIXTURES, 'key.pem');
    const certPath = path.join(FIXTURES, 'cert.pem');
    const serverOptions = givenHttpServerConfig({
      port: 0,
      protocol: 'https',
      key: fs.readFileSync(keyPath),
      cert: fs.readFileSync(certPath),
    });
    const server = await givenAServer({rest: serverOptions});
    server.handler(dummyRequestHandler);
    await server.start();
    const serverUrl = server.getSync(RestBindings.URL);
    const res = await httpsGetAsync(serverUrl);
    expect(res.statusCode).to.equal(200);
  });
github strongloop / loopback-next / examples / hello-world / src / __tests__ / acceptance / application.acceptance.ts View on Github external
function givenAnApplication() {
    app = new HelloWorldApplication({
      rest: givenHttpServerConfig(),
      disableConsoleLog: true,
    });
  }
});
github strongloop / loopback-next / packages / rest / src / __tests__ / acceptance / request-parsing / request-parsing.acceptance.ts View on Github external
async function givenAClient() {
    app = new RestApplication({rest: givenHttpServerConfig()});
    app.controller(
      givenBodyParamController('/show-body-json', 'json'),
      'Controller1',
    );
    app.controller(givenBodyParamController('/show-body'), 'Controller2');
    await app.start();
    client = createRestAppClient(app);
  }
github strongloop / loopback-next / packages / boot / src / __tests__ / acceptance / controller.booter.acceptance.ts View on Github external
async function getApp() {
    await sandbox.copyFile(resolve(__dirname, '../fixtures/package.json'));
    await sandbox.copyFile(resolve(__dirname, '../fixtures/application.js'));
    await sandbox.copyFile(
      resolve(__dirname, '../fixtures/multiple.artifact.js'),
      'controllers/multiple.controller.js',
    );

    const MyApp = require(resolve(SANDBOX_PATH, 'application.js')).BooterApp;
    app = new MyApp({
      rest: givenHttpServerConfig(),
    });
  }
github strongloop / loopback-next / packages / rest / src / __tests__ / integration / rest.server.integration.ts View on Github external
async function givenAServer(
    options: {rest: RestServerConfig} = {rest: {port: 0}},
  ) {
    options.rest = givenHttpServerConfig(options.rest);
    const app = new Application(options);
    app.component(RestComponent);
    return app.getServer(RestServer);
  }
github strongloop / loopback-next / packages / rest-crud / src / __tests__ / acceptance / default-model-crud-rest.acceptance.ts View on Github external
repo = new ProductRepository(db);

    const CrudRestController = defineCrudRestController<
      Product,
      typeof Product.prototype.id,
      'id'
    >(Product, {basePath: '/products'});

    class ProductController extends CrudRestController {
      constructor() {
        super(repo);
      }
    }

    app = new RestApplication({rest: givenHttpServerConfig()});
    app.controller(ProductController);

    await app.start();
    client = createRestAppClient(app);
  }
github strongloop / loopback-next / packages / rest / src / __tests__ / acceptance / file-upload / file-upload-with-parser.acceptance.ts View on Github external
async function givenAClient() {
    app = new RestApplication({rest: givenHttpServerConfig()});
    app.bodyParser(MultipartFormDataBodyParser);
    app.controller(FileUploadController);
    await app.start();
    client = createRestAppClient(app);
  }
});