Skip to content

Commit e4166e2

Browse files
filipesilvaclydin
authored andcommitted
ci: fix ng2 and nightly jobs
1 parent f936eb6 commit e4166e2

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

tests/e2e/tests/build/build-app-shell-with-schematic.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { ng, npm } from '../../utils/process';
22
import { expectFileToMatch } from '../../utils/fs';
33
import { getGlobalVariable } from '../../utils/env';
44
import { expectToFail } from '../../utils/utils';
5+
import { updateJsonFile } from '../../utils/project';
6+
import { readNgVersion } from '../../utils/version';
57

68

79
export default function () {
@@ -15,8 +17,19 @@ export default function () {
1517
return Promise.resolve();
1618
}
1719

20+
let platformServerVersion = readNgVersion();
21+
22+
if (getGlobalVariable('argv').nightly) {
23+
platformServerVersion = 'github:angular/platform-server-builds';
24+
}
25+
26+
1827
return Promise.resolve()
1928
.then(() => ng('generate', 'appShell', 'name', '--universal-app', 'universal'))
29+
.then(() => updateJsonFile('package.json', packageJson => {
30+
const dependencies = packageJson['dependencies'];
31+
dependencies['@angular/platform-server'] = platformServerVersion;
32+
})
2033
.then(() => npm('install'))
2134
.then(() => ng('build', '--prod'))
2235
.then(() => expectFileToMatch('dist/index.html', /app-shell works!/))

tests/e2e/tests/build/build-errors.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ng } from '../../utils/process';
22
import { updateJsonFile } from '../../utils/project';
3-
import { writeFile, appendToFile, readFile } from '../../utils/fs';
3+
import { writeFile, appendToFile, readFile, replaceInFile } from '../../utils/fs';
44
import { getGlobalVariable } from '../../utils/env';
55
import { expectToFail } from '../../utils/utils';
66

@@ -62,11 +62,12 @@ export default function () {
6262
}
6363
})
6464
.then(() => writeFile('./src/app/app.component.ts', origContent))
65-
// Check errors when files were not emitted.
66-
.then(() => writeFile('./src/app/app.component.ts', ''))
65+
// Check errors when files were not emitted due to static analysis errors.
66+
.then(() => replaceInFile('./src/app/app.component.ts', `'app-root'`, `(() => 'app-root')()`))
6767
.then(() => expectToFail(() => ng('build', '--aot')))
6868
.then(({ message }) => {
69-
if (!message.includes(`Unexpected value 'AppComponent`)) {
69+
if (!message.includes('Function calls are not supported')
70+
&& !message.includes('Function expressions are not supported in decorators')) {
7071
throw new Error(`Expected static analysis error, got this instead:\n${message}`);
7172
}
7273
if (extraErrors.some((e) => message.includes(e))) {

tests/e2e/tests/build/platform-server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export default function () {
2121

2222
let platformServerVersion = readNgVersion();
2323

24+
if (getGlobalVariable('argv').nightly) {
25+
platformServerVersion = 'github:angular/platform-server-builds';
26+
}
27+
2428
// Skip this test in Angular 2/4.
2529
if (getGlobalVariable('argv').ng2 || getGlobalVariable('argv').ng4) {
2630
return Promise.resolve();

tests/e2e/tests/build/rebuild-error.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ export default function () {
3737
// Save the original contents of `./src/app/app.component.ts`.
3838
.then(() => readFile('./src/app/app.component.ts'))
3939
.then((contents) => origContent = contents)
40-
// Add a major error on a non-main file to the initial build.
41-
.then(() => writeFile('src/app/app.component.ts', ''))
40+
// Add a major static analysis error on a non-main file to the initial build.
41+
.then(() => replaceInFile('./src/app/app.component.ts', `'app-root'`, `(() => 'app-root')()`))
4242
// Should have an error.
4343
.then(() => execAndWaitForOutputToMatch('ng', ['serve', '--aot'], failedRe))
4444
.then((results) => {
4545
const stderr = results.stderr;
46-
if (!stderr.includes(`Unexpected value 'AppComponent`)) {
46+
if (!stderr.includes('Function calls are not supported')
47+
&& !stderr.includes('Function expressions are not supported in decorators')) {
4748
throw new Error(`Expected static analysis error, got this instead:\n${stderr}`);
4849
}
4950
if (extraErrors.some((e) => stderr.includes(e))) {
@@ -76,18 +77,19 @@ export default function () {
7677
// have an error message in 5s.
7778
.then(() => Promise.all([
7879
expectToFail(() => waitForAnyProcessOutputToMatch(errorRe, 5000)),
79-
replaceInFile('src/app/app.component.ts', ']]]]]', '')
80+
writeFile('src/app/app.component.ts', origContent)
8081
]))
8182
.then(() => wait(2000))
82-
// Add a major error on a rebuild.
83+
// Add a major static analysis error on a rebuild.
8384
// Should fail the rebuild.
8485
.then(() => Promise.all([
8586
waitForAnyProcessOutputToMatch(failedRe, 20000),
86-
writeFile('src/app/app.component.ts', '')
87+
replaceInFile('./src/app/app.component.ts', `'app-root'`, `(() => 'app-root')()`)
8788
]))
8889
.then((results) => {
8990
const stderr = results[0].stderr;
90-
if (!stderr.includes(`Unexpected value 'AppComponent`)) {
91+
if (!stderr.includes('Function calls are not supported')
92+
&& !stderr.includes('Function expressions are not supported in decorators')) {
9193
throw new Error(`Expected static analysis error, got this instead:\n${stderr}`);
9294
}
9395
if (extraErrors.some((e) => stderr.includes(e))) {

tests/e2e/tests/build/script-target.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { expectFileToMatch } from '../../utils/fs';
22
import { ng } from '../../utils/process';
33
import { updateJsonFile } from '../../utils/project';
4+
import { getGlobalVariable } from '../../utils/env';
45

56

67
export default function () {
8+
// Skip this test in Angular 2, it had different bundles.
9+
if (getGlobalVariable('argv').ng2) {
10+
return Promise.resolve();
11+
}
12+
713
return Promise.resolve()
814
.then(() => updateJsonFile('tsconfig.json', configJson => {
915
const compilerOptions = configJson['compilerOptions'];

0 commit comments

Comments
 (0)