Skip to content

Commit 4b70d32

Browse files
committed
test(@angular-devkit/build-angular): validate that libraries source-maps are created
1 parent da74c6e commit 4b70d32

File tree

3 files changed

+64
-25
lines changed

3 files changed

+64
-25
lines changed

tests/legacy-cli/e2e/tests/generate/library/library-consumption-ivy-full.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { writeFile } from '../../../utils/fs';
1+
import { expectFileToMatch, writeFile } from '../../../utils/fs';
22
import { ng } from '../../../utils/process';
33
import { updateJsonFile } from '../../../utils/project';
44

55
export default async function () {
66
await ng('generate', 'library', 'my-lib');
77

8-
await writeFile('./src/app/app.module.ts', `
8+
await writeFile(
9+
'./src/app/app.module.ts',
10+
`
911
import { BrowserModule } from '@angular/platform-browser';
1012
import { NgModule } from '@angular/core';
1113
import { MyLibModule } from 'my-lib';
@@ -24,9 +26,12 @@ export default async function () {
2426
bootstrap: [AppComponent]
2527
})
2628
export class AppModule { }
27-
`);
29+
`,
30+
);
2831

29-
await writeFile('./src/app/app.component.ts', `
32+
await writeFile(
33+
'./src/app/app.component.ts',
34+
`
3035
import { Component } from '@angular/core';
3136
import { MyLibService } from 'my-lib';
3237
@@ -41,9 +46,12 @@ export default async function () {
4146
console.log(myLibService);
4247
}
4348
}
44-
`);
49+
`,
50+
);
4551

46-
await writeFile('e2e/src/app.e2e-spec.ts', `
52+
await writeFile(
53+
'e2e/src/app.e2e-spec.ts',
54+
`
4755
import { browser, logging, element, by } from 'protractor';
4856
import { AppPage } from './app.po';
4957
@@ -67,7 +75,8 @@ export default async function () {
6775
}));
6876
});
6977
});
70-
`);
78+
`,
79+
);
7180

7281
// Build library in full mode (development)
7382
await ng('build', 'my-lib', '--configuration=development');
@@ -76,7 +85,7 @@ export default async function () {
7685
await runTests();
7786

7887
// JIT linking
79-
await updateJsonFile('angular.json', config => {
88+
await updateJsonFile('angular.json', (config) => {
8089
const build = config.projects['test-project'].architect.build;
8190
build.options.aot = false;
8291
build.configurations.production.buildOptimizer = false;
@@ -89,4 +98,8 @@ async function runTests(): Promise<void> {
8998
// Check that the tests succeeds both with named project, unnamed (should test app), and prod.
9099
await ng('e2e');
91100
await ng('e2e', 'test-project', '--devServerTarget=test-project:serve:production');
101+
102+
// Validate that sourcemaps for the library exists.
103+
await ng('build', '--configuration=development');
104+
await expectFileToMatch('dist/test-project/main.js.map', 'projects/my-lib/src/public-api.ts');
92105
}

tests/legacy-cli/e2e/tests/generate/library/library-consumption-ivy-partial.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { writeFile } from '../../../utils/fs';
1+
import { expectFileToMatch, writeFile } from '../../../utils/fs';
22
import { ng } from '../../../utils/process';
33
import { updateJsonFile } from '../../../utils/project';
44

55
export default async function () {
66
await ng('generate', 'library', 'my-lib');
77

8-
await writeFile('./src/app/app.module.ts', `
8+
await writeFile(
9+
'./src/app/app.module.ts',
10+
`
911
import { BrowserModule } from '@angular/platform-browser';
1012
import { NgModule } from '@angular/core';
1113
import { MyLibModule } from 'my-lib';
@@ -24,9 +26,12 @@ export default async function () {
2426
bootstrap: [AppComponent]
2527
})
2628
export class AppModule { }
27-
`);
29+
`,
30+
);
2831

29-
await writeFile('./src/app/app.component.ts', `
32+
await writeFile(
33+
'./src/app/app.component.ts',
34+
`
3035
import { Component } from '@angular/core';
3136
import { MyLibService } from 'my-lib';
3237
@@ -41,9 +46,12 @@ export default async function () {
4146
console.log(myLibService);
4247
}
4348
}
44-
`);
49+
`,
50+
);
4551

46-
await writeFile('e2e/src/app.e2e-spec.ts', `
52+
await writeFile(
53+
'e2e/src/app.e2e-spec.ts',
54+
`
4755
import { browser, logging, element, by } from 'protractor';
4856
import { AppPage } from './app.po';
4957
@@ -67,7 +75,8 @@ export default async function () {
6775
}));
6876
});
6977
});
70-
`);
78+
`,
79+
);
7180

7281
// Build library in partial mode (production)
7382
await ng('build', 'my-lib', '--configuration=production');
@@ -76,7 +85,7 @@ export default async function () {
7685
await runTests();
7786

7887
// JIT linking
79-
await updateJsonFile('angular.json', config => {
88+
await updateJsonFile('angular.json', (config) => {
8089
const build = config.projects['test-project'].architect.build;
8190
build.options.aot = false;
8291
build.configurations.production.buildOptimizer = false;
@@ -89,4 +98,8 @@ async function runTests(): Promise<void> {
8998
// Check that the tests succeeds both with named project, unnamed (should test app), and prod.
9099
await ng('e2e');
91100
await ng('e2e', 'test-project', '--devServerTarget=test-project:serve:production');
101+
102+
// Validate that sourcemaps for the library exists.
103+
await ng('build', '--configuration=development');
104+
await expectFileToMatch('dist/test-project/main.js.map', 'projects/my-lib/src/public-api.ts');
92105
}

tests/legacy-cli/e2e/tests/generate/library/library-consumption-ve.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
import { writeFile } from '../../../utils/fs';
1+
import { expectFileToMatch, writeFile } from '../../../utils/fs';
22
import { ng } from '../../../utils/process';
33
import { updateJsonFile } from '../../../utils/project';
44

55
export default async function () {
66
await ng('generate', 'library', 'my-lib');
77

8-
await updateJsonFile('projects/my-lib/tsconfig.lib.prod.json', config => {
8+
await updateJsonFile('projects/my-lib/tsconfig.lib.prod.json', (config) => {
99
const { angularCompilerOptions = {} } = config;
1010
angularCompilerOptions.enableIvy = false;
1111
angularCompilerOptions.skipTemplateCodegen = true;
1212
angularCompilerOptions.strictMetadataEmit = true;
1313
config.angularCompilerOptions = angularCompilerOptions;
1414
});
1515

16-
await writeFile('./src/app/app.module.ts', `
16+
await writeFile(
17+
'./src/app/app.module.ts',
18+
`
1719
import { BrowserModule } from '@angular/platform-browser';
1820
import { NgModule } from '@angular/core';
1921
import { MyLibModule } from 'my-lib';
@@ -32,9 +34,12 @@ export default async function () {
3234
bootstrap: [AppComponent]
3335
})
3436
export class AppModule { }
35-
`);
37+
`,
38+
);
3639

37-
await writeFile('./src/app/app.component.ts', `
40+
await writeFile(
41+
'./src/app/app.component.ts',
42+
`
3843
import { Component } from '@angular/core';
3944
import { MyLibService } from 'my-lib';
4045
@@ -49,9 +54,12 @@ export default async function () {
4954
console.log(myLibService);
5055
}
5156
}
52-
`);
57+
`,
58+
);
5359

54-
await writeFile('e2e/src/app.e2e-spec.ts', `
60+
await writeFile(
61+
'e2e/src/app.e2e-spec.ts',
62+
`
5563
import { browser, logging, element, by } from 'protractor';
5664
import { AppPage } from './app.po';
5765
@@ -75,7 +83,8 @@ export default async function () {
7583
}));
7684
});
7785
});
78-
`);
86+
`,
87+
);
7988

8089
// Build library in VE mode (production)
8190
await ng('build', 'my-lib', '--configuration=production');
@@ -84,7 +93,7 @@ export default async function () {
8493
await runTests();
8594

8695
// JIT linking
87-
await updateJsonFile('angular.json', config => {
96+
await updateJsonFile('angular.json', (config) => {
8897
const build = config.projects['test-project'].architect.build;
8998
build.options.aot = false;
9099
build.configurations.production.buildOptimizer = false;
@@ -97,4 +106,8 @@ async function runTests(): Promise<void> {
97106
// Check that the tests succeeds both with named project, unnamed (should test app), and prod.
98107
await ng('e2e');
99108
await ng('e2e', 'test-project', '--devServerTarget=test-project:serve:production');
109+
110+
// Validate that sourcemaps for the library exists.
111+
await ng('build', '--configuration=development');
112+
await expectFileToMatch('dist/test-project/main.js.map', 'projects/my-lib/src/public-api.ts');
100113
}

0 commit comments

Comments
 (0)