How to use the @angular-devkit/architect/testing.TestProjectHost function in @angular-devkit/architect

To help you get started, we’ve selected a few @angular-devkit/architect 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 angular / angular-cli / packages / angular_devkit / build_webpack / src / test-utils.ts View on Github external
* @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

import { TestProjectHost } from '@angular-devkit/architect/testing';
import { join, normalize } from '@angular-devkit/core';


const devkitRoot = normalize((global as any)._DevKitRoot); // tslint:disable-line:no-any
const basicWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/basic-app/');
export const basicHost = new TestProjectHost(basicWorkspaceRoot);
const angularWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/angular-app/');
export const angularHost = new TestProjectHost(angularWorkspaceRoot);
github angular / universal / modules / builders / testing / utils.ts View on Github external
cp(
  '-ru',
  testingAppSrc,
  templateRoot,
);

// link node packages
symlinkSync(
  path.join(require.resolve('npm/node_modules/@angular/core/package.json'), '../../../'),
  path.join(process.env.TEST_TMPDIR as string, 'node_modules'),
  'junction'
);

export const workspaceRoot = normalize(templateRoot);
export const host = new TestProjectHost(workspaceRoot);
export const outputPathBrowser = normalize('dist/app/browser');
export const outputPathServer = normalize('dist/app/server');

export async function createArchitect(root: Path) {
  const workspaceSysPath = getSystemPath(root);

  // link @nguniversal packages
  const nodeModuleDir = path.join(workspaceSysPath, 'node_modules');
  if (!existsSync(nodeModuleDir)) {
    mkdirSync(nodeModuleDir);
  }
  const ngUniversalNodePackages = path.join(nodeModuleDir, '@nguniversal');
  if (!existsSync(ngUniversalNodePackages)) {
    mkdirSync(ngUniversalNodePackages);
  }
github angular / angular-cli / packages / angular_devkit / build_webpack / src / test-utils.ts View on Github external
/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

import { TestProjectHost } from '@angular-devkit/architect/testing';
import { join, normalize } from '@angular-devkit/core';


const devkitRoot = normalize((global as any)._DevKitRoot); // tslint:disable-line:no-any
const basicWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/basic-app/');
export const basicHost = new TestProjectHost(basicWorkspaceRoot);
const angularWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/angular-app/');
export const angularHost = new TestProjectHost(angularWorkspaceRoot);
github nrwl / nx / packages / web / src / utils / third-party / utils / build-browser-features_spec.ts View on Github external
* Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

import { TestProjectHost } from '@angular-devkit/architect/testing';
import { getSystemPath, join } from '@angular-devkit/core';
import { ScriptTarget } from 'typescript';
import { BuildBrowserFeatures } from './build-browser-features';

const devkitRoot = (global as any)._DevKitRoot; // tslint:disable-line:no-any
const workspaceRoot = join(
  devkitRoot,
  'tests/angular_devkit/build_angular/hello-world-app/'
);

const host = new TestProjectHost(workspaceRoot);

describe('BuildBrowserFeatures', () => {
  let workspaceRootSysPath = '';
  beforeEach(async () => {
    await host.initialize().toPromise();
    workspaceRootSysPath = getSystemPath(host.root());
  });

  afterEach(async () => host.restore().toPromise());

  describe('isDifferentialLoadingNeeded', () => {
    it('should be true for for IE 9-11 and ES2015', () => {
      host.writeMultipleFiles({
        browserslist: 'IE 9-11'
      });
github angular / angular-cli / packages / angular_devkit / build_angular / src / utils / differential-loading_spec.ts View on Github external
* Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */


import { TestProjectHost } from '@angular-devkit/architect/testing';
import { getSystemPath, join } from '@angular-devkit/core';
import { ScriptTarget } from 'typescript';
import { isDifferentialLoadingNeeded } from './differential-loading';

const devkitRoot = (global as any)._DevKitRoot; // tslint:disable-line:no-any
const workspaceRoot = join(
  devkitRoot,
  'tests/angular_devkit/build_angular/hello-world-app/');

const host = new TestProjectHost(workspaceRoot);


describe('differential loading', () => {

  beforeEach(async () => host.initialize().toPromise());
  afterEach(async () => host.restore().toPromise());

  it('detects the need for differential loading for IE 9-11 and ES2015', () => {
    host.writeMultipleFiles({
      'browserslist': 'IE 9-11',
    });

    const needed = isDifferentialLoadingNeeded(getSystemPath(host.root()), ScriptTarget.ES2015);
    expect(needed).toBe(true);
  });
github alan-agius4 / speedy-build-angular / test / index.spec.ts View on Github external
describe("Stylelint Target", () => {
	const filesWithErrors = { "src/foo.scss": "a { color: #ffffff }" };
	const stylelintTargetSpec = { project: "app", target: "lint" };
	let testArchitectHost: TestingArchitectHost;
	let architect: Architect;
	const workspaceRoot = path.join(__dirname, "hello-world-app");
	const host = new TestProjectHost(normalize(workspaceRoot));

	beforeEach(async () => {
		const registry = new schema.CoreSchemaRegistry();
		registry.addPostTransform(schema.transforms.addUndefinedDefaults);

		const { workspace } = await workspaces.readWorkspace(
			workspaceRoot,
			workspaces.createWorkspaceHost(host)
		);

		await host.initialize().toPromise();

		testArchitectHost = new TestingArchitectHost(
			getSystemPath(host.root()),
			getSystemPath(host.root()),
			new WorkspaceNodeModulesArchitectHost(workspace, workspaceRoot)
github linnenschmidt / build-ng-packagr / packages / builders / src / build-ng-packagr / src / build / index.spec.ts View on Github external
describe('NgPackagr Builder', () => {
  const host = new TestProjectHost(workspaceRoot);
  let architect: Architect;

  beforeEach(async () => {
    await host.initialize().toPromise();

    const registry = new schema.CoreSchemaRegistry();
    registry.addPostTransform(schema.transforms.addUndefinedDefaults);

    const workspaceSysPath = getSystemPath(host.root());
    const { workspace } = await workspaces.readWorkspace(
      workspaceSysPath,
      workspaces.createWorkspaceHost(host),
    );
    const architectHost = new TestingArchitectHost(
      workspaceSysPath,
      workspaceSysPath,
github angular / angular-cli / packages / angular_devkit / build_ng_packagr / src / build / index_spec_large.ts View on Github external
describe('NgPackagr Builder', () => {
  const host = new TestProjectHost(workspaceRoot);
  let architect: Architect;

  beforeEach(async () => {
    await host.initialize().toPromise();

    const registry = new schema.CoreSchemaRegistry();
    registry.addPostTransform(schema.transforms.addUndefinedDefaults);

    const workspaceSysPath = getSystemPath(host.root());
    const { workspace } = await workspaces.readWorkspace(
      workspaceSysPath,
      workspaces.createWorkspaceHost(host),
    );
    const architectHost = new TestingArchitectHost(
      workspaceSysPath,
      workspaceSysPath,