Skip to content

Commit 324b256

Browse files
Alan Agiusmgechev
authored andcommitted
fix(@angular-devkit/build-angular): sourceMap option not working in tests
Fixes #13766
1 parent 3420f66 commit 324b256

File tree

2 files changed

+31
-2
lines changed
  • packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs
  • tests/legacy-cli/e2e/tests/test

2 files changed

+31
-2
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export function getTestConfig(
6060
const { styles, scripts } = wco.buildOptions.sourceMap;
6161

6262
extraPlugins.push(getSourceMapDevTool(
63-
styles,
64-
scripts,
63+
scripts || false,
64+
styles || false,
6565
false,
6666
true,
6767
));
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { writeFile } from '../../utils/fs';
2+
import { execAndWaitForOutputToMatch, killAllProcesses } from '../../utils/process';
3+
import { updateJsonFile } from '../../utils/project';
4+
5+
export default async function () {
6+
await updateJsonFile('angular.json', configJson => {
7+
const appArchitect = configJson.projects['test-project'].architect;
8+
appArchitect.test.options.sourceMap = {
9+
scripts: true,
10+
};
11+
});
12+
13+
await writeFile('src/app/app.component.spec.ts', `
14+
it('show fail', () => {
15+
expect(undefined).toBeTruthy();
16+
});
17+
`);
18+
19+
// when sourcemaps are not working the stacktrace won't point to the spec.ts file.
20+
try {
21+
await execAndWaitForOutputToMatch(
22+
'ng',
23+
['test', '--watch', 'false'],
24+
/app\.component\.spec\.ts/,
25+
);
26+
} finally {
27+
killAllProcesses();
28+
}
29+
}

0 commit comments

Comments
 (0)