Skip to content

Commit 991599c

Browse files
clydinmgechev
authored andcommitted
test(@angular-devkit/build-webpack): use stable workspace API
1 parent 497308e commit 991599c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

packages/angular_devkit/build_webpack/src/webpack-dev-server/index_spec_large.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
import { Architect } from '@angular-devkit/architect';
99
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
1010
import { TestingArchitectHost } from '@angular-devkit/architect/testing';
11-
import { experimental, normalize, schema } from '@angular-devkit/core';
11+
import { schema, workspaces } from '@angular-devkit/core';
1212
import { NodeJsSyncHost } from '@angular-devkit/core/node';
13-
import * as fs from 'fs';
1413
import fetch from 'node-fetch'; // tslint:disable-line:no-implicit-dependencies
1514
import * as path from 'path';
1615
import { DevServerBuildOutput } from './index';
@@ -27,14 +26,14 @@ describe('Dev Server Builder', () => {
2726

2827
async function createArchitect(workspaceRoot: string) {
2928
vfHost = new NodeJsSyncHost();
30-
const configContent = fs.readFileSync(path.join(workspaceRoot, 'angular.json'), 'utf-8');
31-
const workspaceJson = JSON.parse(configContent);
3229

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

36-
const workspace = new experimental.workspace.Workspace(normalize(workspaceRoot), vfHost);
37-
await workspace.loadWorkspaceFromJson(workspaceJson).toPromise();
33+
const { workspace } = await workspaces.readWorkspace(
34+
workspaceRoot,
35+
workspaces.createWorkspaceHost(vfHost),
36+
);
3837

3938
testArchitectHost = new TestingArchitectHost(workspaceRoot, workspaceRoot,
4039
new WorkspaceNodeModulesArchitectHost(workspace, workspaceRoot));

packages/angular_devkit/build_webpack/src/webpack/index_spec_large.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
import { Architect } from '@angular-devkit/architect';
99
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
1010
import { TestingArchitectHost } from '@angular-devkit/architect/testing';
11-
import { experimental, join, normalize, schema } from '@angular-devkit/core';
11+
import { join, normalize, schema, workspaces } from '@angular-devkit/core';
1212
import { NodeJsSyncHost } from '@angular-devkit/core/node';
13-
import * as fs from 'fs';
1413
import * as path from 'path';
1514
import { BuildResult } from './index';
1615

@@ -24,14 +23,14 @@ describe('Webpack Builder basic test', () => {
2423

2524
async function createArchitect(workspaceRoot: string) {
2625
vfHost = new NodeJsSyncHost();
27-
const configContent = fs.readFileSync(path.join(workspaceRoot, 'angular.json'), 'utf-8');
28-
const workspaceJson = JSON.parse(configContent);
2926

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

33-
const workspace = new experimental.workspace.Workspace(normalize(workspaceRoot), vfHost);
34-
await workspace.loadWorkspaceFromJson(workspaceJson).toPromise();
30+
const { workspace } = await workspaces.readWorkspace(
31+
workspaceRoot,
32+
workspaces.createWorkspaceHost(vfHost),
33+
);
3534

3635
testArchitectHost = new TestingArchitectHost(workspaceRoot, workspaceRoot,
3736
new WorkspaceNodeModulesArchitectHost(workspace, workspaceRoot));

0 commit comments

Comments
 (0)