How to use the @angular-devkit/schematics/testing.SchematicTestRunner function in @angular-devkit/schematics

To help you get started, we’ve selected a few @angular-devkit/schematics 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 ng-alain / delon / packages / schematics / utils / testing.ts View on Github external
export function createNgRunner() {
  return new SchematicTestRunner(
    'schematics',
    join('./node_modules/@schematics/angular/collection.json'),
  );
}
github nrwl / nx / packages / storybook / src / utils / testing.ts View on Github external
import { externalSchematic, Rule, Tree } from '@angular-devkit/schematics';
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
import { Architect } from '@angular-devkit/architect';
import { TestingArchitectHost } from '@angular-devkit/architect/testing';

import {
  createEmptyWorkspace,
  MockBuilderContext
} from '@nrwl/workspace/testing';

const testRunner = new SchematicTestRunner(
  '@nrwl/storybook',
  join(__dirname, '../../collection.json')
);

const migrationRunner = new SchematicTestRunner(
  '@nrwl/storybook/migrations',
  join(__dirname, '../../migrations.json')
);

export function runSchematic(
  schematicName: string,
  options: SchemaOptions,
  tree: Tree
) {
  return testRunner.runSchematicAsync(schematicName, options, tree).toPromise();
}

export function callRule(rule: Rule, tree: Tree) {
  return testRunner.callRule(rule, tree).toPromise();
}
github nrwl / nx / packages / cypress / src / utils / testing.ts View on Github external
import { join } from 'path';
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
import { Tree, Rule } from '@angular-devkit/schematics';

const testRunner = new SchematicTestRunner(
  '@nrwl/cypress',
  join(__dirname, '../../collection.json')
);

const migrationRunner = new SchematicTestRunner(
  '@nrwl/cypress/migrations',
  join(__dirname, '../../migrations.json')
);

export function runSchematic(schematicName: string, options: any, tree: Tree) {
  return testRunner.runSchematicAsync(schematicName, options, tree).toPromise();
}

export function callRule(rule: Rule, tree: Tree) {
  return testRunner.callRule(rule, tree).toPromise();
}
github angular / components / src / cdk / schematics / ng-generate / drag-drop / index.spec.ts View on Github external
beforeEach(() => {
    runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
  });
github FortAwesome / angular-fontawesome / projects / schematics / src / ng-add / index.spec.ts View on Github external
const setup = async () => {
  const runner = new SchematicTestRunner('schematics', collectionPath);

  const appTree = await runner
    .runExternalSchematicAsync(
      '@schematics/angular',
      'ng-new',
      {
        name: 'test-app',
        version: '9.0.0-rc.6',
        directory: '.',
      },
      Tree.empty(),
    )
    .toPromise();

  return { runner, appTree };
};
github positive-js / mosaic / packages / cdk / schematics / ng-add / index.spec.ts View on Github external
beforeEach(() => {
    runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
    appTree = createTestApp(runner);
  });