From e2c7502730a69e8b4b15bd0d4abccac7321b79f3 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 9 Jun 2022 14:29:20 +0000 Subject: [PATCH] test: split module resolutions E2E in multiple tests This test does a large number of builds by spliting the tests, in CI we can reduce the blocking time for other tests. Locally this tests take ~3 mins in CI. --- .../e2e/tests/misc/module-resolution.ts | 84 ------------------- .../module-resolution-core-mapping.ts | 41 +++++++++ .../module-resolution-firebase.ts | 45 ++++++++++ 3 files changed, 86 insertions(+), 84 deletions(-) delete mode 100644 tests/legacy-cli/e2e/tests/misc/module-resolution.ts create mode 100644 tests/legacy-cli/e2e/tests/misc/module-resolution/module-resolution-core-mapping.ts create mode 100644 tests/legacy-cli/e2e/tests/misc/module-resolution/module-resolution-firebase.ts diff --git a/tests/legacy-cli/e2e/tests/misc/module-resolution.ts b/tests/legacy-cli/e2e/tests/misc/module-resolution.ts deleted file mode 100644 index 1314fb4a3c..0000000000 --- a/tests/legacy-cli/e2e/tests/misc/module-resolution.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { appendToFile, createDir, moveFile, prependToFile } from '../../utils/fs'; -import { installPackage } from '../../utils/packages'; -import { ng } from '../../utils/process'; -import { updateJsonFile } from '../../utils/project'; -import { expectToFail } from '../../utils/utils'; - -export default async function () { - await updateJsonFile('tsconfig.json', (tsconfig) => { - tsconfig.compilerOptions.paths = { - '*': ['./node_modules/*'], - }; - }); - await ng('build', '--configuration=development'); - - await createDir('xyz'); - await moveFile('node_modules/@angular/common', 'xyz/common'); - - await expectToFail(() => ng('build', '--configuration=development')); - - await updateJsonFile('tsconfig.json', (tsconfig) => { - tsconfig.compilerOptions.paths = { - '@angular/common': ['./xyz/common'], - }; - }); - await ng('build', '--configuration=development'); - - await updateJsonFile('tsconfig.json', (tsconfig) => { - tsconfig.compilerOptions.paths = { - '*': ['./node_modules/*'], - '@angular/common': ['./xyz/common'], - }; - }); - await ng('build', '--configuration=development'); - - await updateJsonFile('tsconfig.json', (tsconfig) => { - tsconfig.compilerOptions.paths = { - '@angular/common': ['./xyz/common'], - '*': ['./node_modules/*'], - }; - }); - await ng('build', '--configuration=development'); - - await updateJsonFile('tsconfig.json', (tsconfig) => { - delete tsconfig.compilerOptions.paths; - }); - - await prependToFile('src/app/app.module.ts', "import * as firebase from 'firebase';"); - await appendToFile('src/app/app.module.ts', 'firebase.initializeApp({});'); - - await installPackage('firebase@3.7.8'); - await ng('build', '--aot', '--configuration=development'); - await ng('test', '--watch=false'); - - await installPackage('firebase@4.9.0'); - await ng('build', '--aot', '--configuration=development'); - await ng('test', '--watch=false'); - - await updateJsonFile('tsconfig.json', (tsconfig) => { - tsconfig.compilerOptions.paths = {}; - }); - await ng('build', '--configuration=development'); - - await updateJsonFile('tsconfig.json', (tsconfig) => { - tsconfig.compilerOptions.paths = { - '@app/*': ['*'], - '@lib/*/test': ['*/test'], - }; - }); - await ng('build', '--configuration=development'); - - await updateJsonFile('tsconfig.json', (tsconfig) => { - tsconfig.compilerOptions.paths = { - '@firebase/polyfill': ['./node_modules/@firebase/polyfill/index.ts'], - }; - }); - await expectToFail(() => ng('build', '--configuration=development')); - - await updateJsonFile('tsconfig.json', (tsconfig) => { - tsconfig.compilerOptions.paths = { - '@firebase/polyfill*': ['./node_modules/@firebase/polyfill/index.ts'], - }; - }); - await expectToFail(() => ng('build', '--configuration=development')); -} diff --git a/tests/legacy-cli/e2e/tests/misc/module-resolution/module-resolution-core-mapping.ts b/tests/legacy-cli/e2e/tests/misc/module-resolution/module-resolution-core-mapping.ts new file mode 100644 index 0000000000..2efae0ea54 --- /dev/null +++ b/tests/legacy-cli/e2e/tests/misc/module-resolution/module-resolution-core-mapping.ts @@ -0,0 +1,41 @@ +import { createDir, moveFile } from '../../../utils/fs'; +import { ng } from '../../../utils/process'; +import { updateJsonFile } from '../../../utils/project'; +import { expectToFail } from '../../../utils/utils'; + +export default async function () { + await updateJsonFile('tsconfig.json', (tsconfig) => { + tsconfig.compilerOptions.paths = { + '*': ['./node_modules/*'], + }; + }); + await ng('build', '--configuration=development'); + + await createDir('xyz'); + await moveFile('node_modules/@angular/common', 'xyz/common'); + await expectToFail(() => ng('build', '--configuration=development')); + + await updateJsonFile('tsconfig.json', (tsconfig) => { + tsconfig.compilerOptions.paths = { + '@angular/common': ['./xyz/common'], + }; + }); + await ng('build', '--configuration=development'); + + await updateJsonFile('tsconfig.json', (tsconfig) => { + tsconfig.compilerOptions.paths = { + '*': ['./node_modules/*'], + '@angular/common': ['./xyz/common'], + }; + }); + await ng('build', '--configuration=development'); + + await updateJsonFile('tsconfig.json', (tsconfig) => { + tsconfig.compilerOptions.paths = { + '@angular/common': ['./xyz/common'], + '*': ['./node_modules/*'], + }; + }); + await ng('build', '--configuration=development'); + await moveFile('xyz/common', 'node_modules/@angular/common'); +} diff --git a/tests/legacy-cli/e2e/tests/misc/module-resolution/module-resolution-firebase.ts b/tests/legacy-cli/e2e/tests/misc/module-resolution/module-resolution-firebase.ts new file mode 100644 index 0000000000..329ad2ef6e --- /dev/null +++ b/tests/legacy-cli/e2e/tests/misc/module-resolution/module-resolution-firebase.ts @@ -0,0 +1,45 @@ +import { appendToFile, prependToFile } from '../../../utils/fs'; +import { installPackage } from '../../../utils/packages'; +import { ng } from '../../../utils/process'; +import { updateJsonFile } from '../../../utils/project'; +import { expectToFail } from '../../../utils/utils'; + +export default async function () { + await updateJsonFile('tsconfig.json', (tsconfig) => { + delete tsconfig.compilerOptions.paths; + }); + + await prependToFile('src/app/app.module.ts', "import * as firebase from 'firebase';"); + await appendToFile('src/app/app.module.ts', 'firebase.initializeApp({});'); + + await installPackage('firebase@4.9.0'); + await ng('build', '--aot', '--configuration=development'); + + await updateJsonFile('tsconfig.json', (tsconfig) => { + tsconfig.compilerOptions.paths = {}; + }); + + await ng('build', '--configuration=development'); + await updateJsonFile('tsconfig.json', (tsconfig) => { + tsconfig.compilerOptions.paths = { + '@app/*': ['*'], + '@lib/*/test': ['*/test'], + }; + }); + + await ng('build', '--configuration=development'); + await updateJsonFile('tsconfig.json', (tsconfig) => { + tsconfig.compilerOptions.paths = { + '@firebase/polyfill': ['./node_modules/@firebase/polyfill/index.ts'], + }; + }); + + await expectToFail(() => ng('build', '--configuration=development')); + + await updateJsonFile('tsconfig.json', (tsconfig) => { + tsconfig.compilerOptions.paths = { + '@firebase/polyfill*': ['./node_modules/@firebase/polyfill/index.ts'], + }; + }); + await expectToFail(() => ng('build', '--configuration=development')); +}