How to use the @loopback/testlab.skipIf 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 / packages / context / src / __tests__ / unit / interceptor.unit.ts View on Github external
const invocationCtx = givenInvocationContext();

    const keys = invocationCtx.getGlobalInterceptorBindingKeys();
    expect(keys).to.eql([
      'globalInterceptors.authInterceptor',
      'globalInterceptors.logInterceptor',
    ]);
  });

  // See https://v8.dev/blog/array-sort
  function isSortStable() {
    // v8 7.0 or above
    return +process.versions.v8.split('.')[0] >= 7;
  }

  skipIf(
    !isSortStable(),
    it,
    'sorts by binding order without group tags',
    async () => {
      ctx
        .bind('globalInterceptors.authInterceptor')
        .to(authInterceptor)
        .apply(asGlobalInterceptor());

      ctx
        .bind('globalInterceptors.logInterceptor')
        .to(logInterceptor)
        .apply(asGlobalInterceptor());

      const invocationCtx = givenInvocationContext();
github strongloop / loopback-next / packages / repository-tests / src / crud / relations / acceptance / has-many-inclusion-resolver.relation.acceptance.ts View on Github external
...odin,
          parentId: features.emptyValue,
          orders: [
            {
              ...odinPizza,
              isShipped: features.emptyValue,
              // eslint-disable-next-line @typescript-eslint/camelcase
              shipment_id: features.emptyValue,
            },
          ],
        };
        expect(toJSON(result)).to.containEql(toJSON(expected));
      },
    );

    skipIf(
      features.hasRevisionToken,
      it,
      'returns inclusions after running replaceById() operation',
      async () => {
        // this shows replaceById() works well with func ensurePersistable and ObjectId
        // the test skips for Cloudant as it needs the _rev property for replacement.
        // see replace-by-id.suite.ts
        const thor = await customerRepo.create({name: 'Thor'});
        const odin = await customerRepo.create({name: 'Odin'});

        const thorOrder = await orderRepo.create({
          customerId: thor.id,
          description: 'Pizza',
        });

        const pizza = await orderRepo.findById(thorOrder.id.toString());
github strongloop / loopback-next / packages / repository-tests / src / crud / relations / acceptance / multi-relations-inclusion-resolver.relation.acceptance.ts View on Github external
export function hasManyInclusionResolverAcceptance(
  dataSourceOptions: DataSourceOptions,
  repositoryClass: CrudRepositoryCtor,
  features: CrudFeatures,
) {
  skipIf<[(this: Suite) => void], void>(
    !features.supportsInclusionResolvers,
    describe,
    'Multi relations inclusion resolvers - acceptance',
    suite,
  );
  function suite() {
    before(deleteAllModelsInDefaultDataSource);
    let customerRepo: CustomerRepository;
    let orderRepo: OrderRepository;

    before(
      withCrudCtx(async function setupRepository(ctx: CrudTestContext) {
        // this helper should create the inclusion resolvers and also
        // register inclusion resolvers for us
        ({customerRepo, orderRepo} = givenBoundCrudRepositories(
          ctx.dataSource,
github strongloop / loopback-next / packages / repository-tests / src / crud / relations / acceptance / has-many-inclusion-resolver.relation.acceptance.ts View on Github external
export function hasManyInclusionResolverAcceptance(
  dataSourceOptions: DataSourceOptions,
  repositoryClass: CrudRepositoryCtor,
  features: CrudFeatures,
) {
  skipIf<[(this: Suite) => void], void>(
    !features.supportsInclusionResolvers,
    describe,
    'HasMany inclusion resolvers - acceptance',
    suite,
  );
  function suite() {
    before(deleteAllModelsInDefaultDataSource);
    let customerRepo: CustomerRepository;
    let orderRepo: OrderRepository;

    before(
      withCrudCtx(async function setupRepository(ctx: CrudTestContext) {
        // this helper should create the inclusion resolvers and also
        // register inclusion resolvers for us
        ({customerRepo, orderRepo} = givenBoundCrudRepositories(
          ctx.dataSource,
github strongloop / loopback-next / packages / repository-tests / src / crud / relations / acceptance / has-many-inclusion-resolver.relation.acceptance.ts View on Github external
const expected = {
        ...odin,
        parentId: features.emptyValue,
        orders: [
          {
            ...odinOrder,
            isShipped: features.emptyValue,
            // eslint-disable-next-line @typescript-eslint/camelcase
            shipment_id: features.emptyValue,
          },
        ],
      };
      expect(toJSON(result)).to.deepEqual(toJSON(expected));
    });

    skipIf(
      features.hasRevisionToken,
      it,
      'returns inclusions after running save() operation',
      async () => {
        // this shows save() works well with func ensurePersistable and ObjectId
        // the test skips for Cloudant as it needs the _rev property for replacement.
        // see replace-by-id.suite.ts
        const thor = await customerRepo.create({name: 'Thor'});
        const odin = await customerRepo.create({name: 'Odin'});

        const thorOrder = await orderRepo.create({
          customerId: thor.id,
          description: 'Pizza',
        });

        const pizza = await orderRepo.findById(thorOrder.id);
github strongloop / loopback-next / packages / repository-tests / src / crud / relations / acceptance / has-one.inclusion-resolver.acceptance.ts View on Github external
export function hasOneInclusionResolverAcceptance(
  dataSourceOptions: DataSourceOptions,
  repositoryClass: CrudRepositoryCtor,
  features: CrudFeatures,
) {
  skipIf<[(this: Suite) => void], void>(
    !features.supportsInclusionResolvers,
    describe,
    'HasOne inclusion resolvers - acceptance',
    suite,
  );
  function suite() {
    before(deleteAllModelsInDefaultDataSource);
    let customerRepo: CustomerRepository;
    let addressRepo: AddressRepository;

    before(
      withCrudCtx(async function setupRepository(ctx: CrudTestContext) {
        // this helper should create the inclusion resolvers and also
        // register inclusion resolvers for us
        ({customerRepo, addressRepo} = givenBoundCrudRepositories(
          ctx.dataSource,
github strongloop / loopback-next / packages / repository-tests / src / crud / relations / acceptance / belongs-to.inclusion-resolver.relation.acceptance.ts View on Github external
export function belongsToInclusionResolverAcceptance(
  dataSourceOptions: DataSourceOptions,
  repositoryClass: CrudRepositoryCtor,
  features: CrudFeatures,
) {
  skipIf<[(this: Suite) => void], void>(
    !features.supportsInclusionResolvers,
    describe,
    'BelongsTo inclusion resolvers - acceptance',
    suite,
  );
  function suite() {
    before(deleteAllModelsInDefaultDataSource);
    let customerRepo: CustomerRepository;
    let orderRepo: OrderRepository;

    before(
      withCrudCtx(async function setupRepository(ctx: CrudTestContext) {
        // this helper should create the inclusion resolvers and also
        // register inclusion resolvers for us
        ({customerRepo, orderRepo} = givenBoundCrudRepositories(
          ctx.dataSource,
github strongloop / loopback-next / packages / repository-tests / src / crud / transactions.suite.ts View on Github external
export function transactionSuite(
  dataSourceOptions: DataSourceOptions,
  repositoryClass: TransactionalRepositoryCtor,
  connectorFeatures: CrudFeatures,
) {
  skipIf<[(this: Suite) => void], void>(
    !connectorFeatures.supportsTransactions,
    describe,
    `transactions`,
    () => {
      @model()
      class Product extends Entity {
        @property({
          type: connectorFeatures.idType,
          id: true,
          generated: true,
          description: 'The unique identifier for a product',
        })
        id: MixedIdType;

        @property({type: 'string', required: true})
        name: string;
github strongloop / loopback-next / packages / repository-tests / src / crud / retrieve-including-relations.suite.ts View on Github external
mongodb: {
        dataType: 'ObjectID',
      },
    })
    categoryId: number | string;

    constructor(data?: Partial) {
      super(data);
    }
  }

  interface ItemRelations {
    category?: Category;
  }

  skipIf<[(this: Suite) => void], void>(
    !features.inclusionResolvers,
    describe,
    'retrieve models including relations',
    () => {
      let categoryRepo: EntityCrudRepository<
        Category,
        typeof Category.prototype.id,
        CategoryRelations
      >;
      let itemRepo: EntityCrudRepository<
        Item,
        typeof Item.prototype.id,
        ItemRelations
      >;
      before(
        withCrudCtx(async function setupRepository(ctx: CrudTestContext) {