Skip to content

Commit

Permalink
test: simplify test sourcemaps e2e test
Browse files Browse the repository at this point in the history
(cherry picked from commit 59fe830)
  • Loading branch information
alan-agius4 committed Jun 13, 2022
1 parent 23095e9 commit 76d0115
Showing 1 changed file with 2 additions and 30 deletions.
32 changes: 2 additions & 30 deletions tests/legacy-cli/e2e/tests/test/test-sourcemap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { writeFile } from '../../utils/fs';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';

export default async function () {
await writeFile(
Expand All @@ -12,46 +11,19 @@ export default async function () {
`,
);

await updateJsonFile('angular.json', (configJson) => {
const appArchitect = configJson.projects['test-project'].architect;
appArchitect.test.options.sourceMap = {
scripts: true,
};
});

// when sourcemaps are 'on' the stacktrace will point to the spec.ts file.
try {
await ng('test', '--watch', 'false');
throw new Error('ng test should have failed.');
} catch (error) {
if (!error.message.includes('app.component.spec.ts')) {
throw error;
}
}

await updateJsonFile('angular.json', (configJson) => {
const appArchitect = configJson.projects['test-project'].architect;
appArchitect.test.options.sourceMap = true;
});

// when sourcemaps are 'on' the stacktrace will point to the spec.ts file.
try {
await ng('test', '--watch', 'false');
await ng('test', '--no-watch', '--source-map');
throw new Error('ng test should have failed.');
} catch (error) {
if (!error.message.includes('app.component.spec.ts')) {
throw error;
}
}

await updateJsonFile('angular.json', (configJson) => {
const appArchitect = configJson.projects['test-project'].architect;
appArchitect.test.options.sourceMap = false;
});

// when sourcemaps are 'off' the stacktrace won't point to the spec.ts file.
try {
await ng('test', '--watch', 'false');
await ng('test', '--no-watch', '--no-source-map');
throw new Error('ng test should have failed.');
} catch (error) {
if (!error.message.includes('main.js')) {
Expand Down

0 comments on commit 76d0115

Please sign in to comment.