Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running the E2E test suite with yarn #19077

Merged
merged 3 commits into from Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .circleci/config.yml
Expand Up @@ -199,6 +199,11 @@ jobs:
- run:
name: Execute CLI E2E Tests
command: PATH=~/.npm-global/bin:$PATH node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} <<# parameters.ve >>--ve<</ parameters.ve >> <<# parameters.snapshots >>--ng-snapshots<</ parameters.snapshots >> --tmpdir=/mnt/ramdisk
- run:
name: Execute CLI E2E Tests Subset with Yarn
command: |
rm -rf /mnt/ramdisk/*test-project
PATH=~/.npm-global/bin:$PATH node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} <<# parameters.ve >>--ve<</ parameters.ve >> <<# parameters.snapshots >>--ng-snapshots<</ parameters.snapshots >> --yarn --tmpdir=/mnt/ramdisk --glob="{tests/basic/**,tests/update/**}"

e2e-cli-node-10:
executor:
Expand Down
@@ -1,6 +1,7 @@
import { getGlobalVariable } from '../../utils/env';
import { appendToFile, expectFileToMatch } from '../../utils/fs';
import { ng, silentNpm } from '../../utils/process';
import { installPackage } from '../../utils/packages';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';

const snapshots = require('../../ng-snapshot/package.json');
Expand All @@ -23,7 +24,7 @@ export default async function () {
});

for (const pkg of packagesToInstall) {
await silentNpm('install', pkg);
await installPackage(pkg);
}
}

Expand Down
5 changes: 3 additions & 2 deletions tests/legacy-cli/e2e/tests/build/build-app-shell.ts
@@ -1,7 +1,8 @@
import { stripIndent } from 'common-tags';
import { getGlobalVariable } from '../../utils/env';
import { expectFileToMatch, writeFile } from '../../utils/fs';
import { ng, npm } from '../../utils/process';
import { installWorkspacePackages } from '../../utils/packages';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { readNgVersion } from '../../utils/version';

Expand Down Expand Up @@ -159,7 +160,7 @@ export default function() {
updateJsonFile('package.json', packageJson => {
const dependencies = packageJson['dependencies'];
dependencies['@angular/platform-server'] = platformServerVersion;
}).then(() => npm('install')),
}).then(() => installWorkspacePackages()),
)
.then(() => ng('run', 'test-project:app-shell'))
.then(() => expectFileToMatch('dist/test-project/index.html', /shell Works!/));
Expand Down
9 changes: 5 additions & 4 deletions tests/legacy-cli/e2e/tests/build/material.ts
@@ -1,6 +1,7 @@
import { getGlobalVariable } from '../../utils/env';
import { replaceInFile } from '../../utils/fs';
import { ng, silentNpm } from '../../utils/process';
import { installPackage, installWorkspacePackages } from '../../utils/packages';
import { ng } from '../../utils/process';
import { isPrereleaseCli, updateJsonFile } from '../../utils/project';

const snapshots = require('../../ng-snapshot/package.json');
Expand All @@ -25,12 +26,12 @@ export default async function () {
snapshots.dependencies['@angular/material-moment-adapter'];
});

await silentNpm('install');
await installWorkspacePackages();
} else {
await silentNpm('install', '@angular/material-moment-adapter');
await installPackage('@angular/material-moment-adapter');
}

await silentNpm('install', 'moment');
await installPackage('moment');

await ng('build', '--prod');

Expand Down
3 changes: 2 additions & 1 deletion tests/legacy-cli/e2e/tests/build/platform-server.ts
@@ -1,6 +1,7 @@
import { normalize } from 'path';
import { getGlobalVariable } from '../../utils/env';
import { appendToFile, expectFileToMatch, writeFile } from '../../utils/fs';
import { installPackage } from '../../utils/packages';
import { exec, ng, silentNpm } from '../../utils/process';
import { isPrereleaseCli, updateJsonFile } from '../../utils/project';

Expand Down Expand Up @@ -37,7 +38,7 @@ export default async function () {
});

for (const pkg of packagesToInstall) {
await silentNpm('install', pkg);
await installPackage(pkg);
}
}

Expand Down
7 changes: 4 additions & 3 deletions tests/legacy-cli/e2e/tests/build/service-worker.ts
@@ -1,7 +1,8 @@
import {join} from 'path';
import {getGlobalVariable} from '../../utils/env';
import {expectFileNotToExist, expectFileToExist, expectFileToMatch, writeFile} from '../../utils/fs';
import {ng, npm, silentNpm} from '../../utils/process';
import { installPackage, uninstallPackage } from '../../utils/packages';
import {ng} from '../../utils/process';

const MANIFEST = {
index: '/index.html',
Expand All @@ -25,8 +26,8 @@ const MANIFEST = {
export default function() {
// Can't use the `ng` helper because somewhere the environment gets
// stuck to the first build done
return silentNpm('remove', '@angular/service-worker')
.then(() => silentNpm('install', '@angular/service-worker'))
return uninstallPackage('@angular/service-worker')
.then(() => installPackage('@angular/service-worker'))
.then(() => ng('config', 'projects.test-project.architect.build.options.serviceWorker', 'true'))
.then(() => writeFile('src/ngsw-config.json', JSON.stringify(MANIFEST, null, 2)))
.then(() => ng('build', '--optimization'))
Expand Down
5 changes: 3 additions & 2 deletions tests/legacy-cli/e2e/tests/build/styles/material-import.ts
Expand Up @@ -4,7 +4,8 @@ import {
replaceInFile,
writeMultipleFiles,
} from '../../../utils/fs';
import { ng, silentNpm } from '../../../utils/process';
import { installWorkspacePackages } from '../../../utils/packages';
import { ng } from '../../../utils/process';
import { updateJsonFile } from '../../../utils/project';

const snapshots = require('../../../ng-snapshot/package.json');
Expand All @@ -19,7 +20,7 @@ export default async function () {
dependencies['@angular/cdk'] = isSnapshotBuild ? snapshots.dependencies['@angular/cdk'] : 'latest';
});

await silentNpm('install');
await installWorkspacePackages();

for (const ext of ['css', 'scss', 'less', 'styl']) {
await writeMultipleFiles({
Expand Down
11 changes: 6 additions & 5 deletions tests/legacy-cli/e2e/tests/build/styles/node-sass.ts
Expand Up @@ -4,7 +4,8 @@ import {
replaceInFile,
writeMultipleFiles,
} from '../../../utils/fs';
import { ng, silentExec, silentNpm } from '../../../utils/process';
import { installPackage } from '../../../utils/packages';
import { ng, silentExec } from '../../../utils/process';
import { updateJsonFile } from '../../../utils/project';
import { expectToFail } from '../../../utils/utils';

Expand Down Expand Up @@ -32,7 +33,7 @@ export default async function () {
await silentExec('rm', '-rf', 'node_modules/sass');
await expectToFail(() => ng('build', '--extract-css', '--source-map'));

await silentNpm('install', 'node-sass');
await installPackage('node-sass');
await silentExec('rm', '-rf', 'node_modules/sass');
await ng('build', '--extract-css', '--source-map');

Expand All @@ -41,9 +42,9 @@ export default async function () {
await expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""'));
await expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/);

await silentNpm('install', 'node-gyp');
await silentNpm('install', 'fibers');
await silentNpm('install', 'sass');
await installPackage('node-gyp');
await installPackage('fibers');
await installPackage('sass');
await silentExec('rm', '-rf', 'node_modules/node-sass');
await ng('build', '--extract-css', '--source-map');

Expand Down
21 changes: 0 additions & 21 deletions tests/legacy-cli/e2e/tests/build/typescript/typescript-2_7.ts

This file was deleted.

5 changes: 5 additions & 0 deletions tests/legacy-cli/e2e/tests/commands/add/add-pwa-yarn.ts
@@ -1,8 +1,13 @@
import { join } from 'path';
import { getGlobalVariable } from '../../../utils/env';
import { expectFileToExist, readFile, rimraf } from '../../../utils/fs';
import { ng, npm } from '../../../utils/process';

export default async function () {
if (getGlobalVariable('package-manager') === 'yarn') {
return;
}

// forcibly remove in case another test doesn't clean itself up
await rimraf('node_modules/@angular/pwa');

Expand Down
7 changes: 4 additions & 3 deletions tests/legacy-cli/e2e/tests/i18n/extract-ivy-libraries.ts
@@ -1,6 +1,7 @@
import { getGlobalVariable } from '../../utils/env';
import { expectFileToMatch, replaceInFile, writeFile } from '../../utils/fs';
import { ng, npm } from '../../utils/process';
import { installPackage, uninstallPackage } from '../../utils/packages';
import { ng } from '../../utils/process';
import { readNgVersion } from '../../utils/version';

export default async function() {
Expand Down Expand Up @@ -57,7 +58,7 @@ export default async function() {
if (getGlobalVariable('argv')['ng-snapshots']) {
localizeVersion = require('../../ng-snapshot/package.json').dependencies['@angular/localize'];
}
await npm('install', `${localizeVersion}`);
await installPackage(localizeVersion);

// Extract messages
await ng('xi18n', '--ivy');
Expand All @@ -69,5 +70,5 @@ export default async function() {
'projects/i18n-lib-test/src/lib/i18n-lib-test.component.ts',
);

await npm('uninstall', '@angular/localize');
await uninstallPackage('@angular/localize');
}
7 changes: 4 additions & 3 deletions tests/legacy-cli/e2e/tests/i18n/extract-ivy.ts
@@ -1,7 +1,8 @@
import { join } from 'path';
import { getGlobalVariable } from '../../utils/env';
import { writeFile } from '../../utils/fs';
import { ng, npm } from '../../utils/process';
import { installPackage, uninstallPackage } from '../../utils/packages';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
import { readNgVersion } from '../../utils/version';
Expand Down Expand Up @@ -30,7 +31,7 @@ export default async function() {
if (getGlobalVariable('argv')['ng-snapshots']) {
localizeVersion = require('../../ng-snapshot/package.json').dependencies['@angular/localize'];
}
await npm('install', `${localizeVersion}`);
await installPackage(localizeVersion);

// Should show ivy enabled application warning without --ivy flag
const { stderr: message3 } = await ng('xi18n', '--no-ivy');
Expand All @@ -57,5 +58,5 @@ export default async function() {
throw new Error('Expected ivy disabled application warning');
}

await npm('uninstall', '@angular/localize');
await uninstallPackage('@angular/localize');
}
5 changes: 3 additions & 2 deletions tests/legacy-cli/e2e/tests/i18n/ivy-localize-app-shell.ts
Expand Up @@ -7,7 +7,8 @@ import {
replaceInFile,
writeFile,
} from '../../utils/fs';
import { ng, silentNpm } from '../../utils/process';
import { installWorkspacePackages } from '../../utils/packages';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { readNgVersion } from '../../utils/version';

Expand Down Expand Up @@ -38,7 +39,7 @@ export default async function () {
});
}

await silentNpm('install');
await installWorkspacePackages();

const browserBaseDir = 'dist/test-project/browser';

Expand Down
5 changes: 3 additions & 2 deletions tests/legacy-cli/e2e/tests/i18n/ivy-localize-server.ts
Expand Up @@ -2,7 +2,8 @@ import * as express from 'express';
import { join } from 'path';
import { getGlobalVariable } from '../../utils/env';
import { appendToFile, expectFileToMatch, writeFile } from '../../utils/fs';
import { ng, silentNpm } from '../../utils/process';
import { installWorkspacePackages } from '../../utils/packages';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
import { langTranslations, setupI18nConfig } from './legacy';
Expand All @@ -27,7 +28,7 @@ export default async function () {
});
}

await silentNpm('install');
await installWorkspacePackages();

const serverbaseDir = 'dist/test-project/server';
const serverBuildArgs = ['run', 'test-project:server'];
Expand Down
7 changes: 4 additions & 3 deletions tests/legacy-cli/e2e/tests/i18n/ivy-localize-serviceworker.ts
Expand Up @@ -8,7 +8,8 @@ import {
replaceInFile,
writeFile,
} from '../../utils/fs';
import { ng, npm } from '../../utils/process';
import { installPackage } from '../../utils/packages';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
import { readNgVersion } from '../../utils/version';
Expand All @@ -22,15 +23,15 @@ export default async function() {
if (getGlobalVariable('argv')['ng-snapshots']) {
localizeVersion = require('../../ng-snapshot/package.json').dependencies['@angular/localize'];
}
await npm('install', `${localizeVersion}`);
await installPackage(localizeVersion);

let serviceWorkerVersion = '@angular/service-worker@' + readNgVersion();
if (getGlobalVariable('argv')['ng-snapshots']) {
serviceWorkerVersion = require('../../ng-snapshot/package.json').dependencies[
'@angular/service-worker'
];
}
await npm('install', `${serviceWorkerVersion}`);
await installPackage(serviceWorkerVersion);

await updateJsonFile('tsconfig.json', config => {
config.compilerOptions.target = 'es2015';
Expand Down
5 changes: 3 additions & 2 deletions tests/legacy-cli/e2e/tests/i18n/legacy.ts
Expand Up @@ -2,7 +2,8 @@ import * as express from 'express';
import { resolve } from 'path';
import { getGlobalVariable } from '../../utils/env';
import { appendToFile, copyFile, expectFileToExist, expectFileToMatch, replaceInFile, writeFile } from '../../utils/fs';
import { ng, npm } from '../../utils/process';
import { installPackage } from '../../utils/packages';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
import { readNgVersion } from '../../utils/version';
Expand Down Expand Up @@ -213,7 +214,7 @@ export async function setupI18nConfig(useLocalize = true, format: keyof typeof f
if (getGlobalVariable('argv')['ng-snapshots']) {
localizeVersion = require('../../ng-snapshot/package.json').dependencies['@angular/localize'];
}
await npm('install', `${localizeVersion}`);
await installPackage(localizeVersion);
}

// Extract the translation messages.
Expand Down
7 changes: 4 additions & 3 deletions tests/legacy-cli/e2e/tests/i18n/ve-localize-es2015.ts
@@ -1,10 +1,11 @@
import { getGlobalVariable } from '../../utils/env';
import { expectFileToMatch, writeFile } from '../../utils/fs';
import { execAndWaitForOutputToMatch, ng, npm } from '../../utils/process';
import { installPackage } from '../../utils/packages';
import { execAndWaitForOutputToMatch, ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
import { readNgVersion } from '../../utils/version';
import { baseDir, externalServer, langTranslations, setupI18nConfig } from './legacy';
import { externalServer, langTranslations, setupI18nConfig } from './legacy';

export default async function() {
if (!getGlobalVariable('argv')['ve']) {
Expand All @@ -19,7 +20,7 @@ export default async function() {
if (getGlobalVariable('argv')['ng-snapshots']) {
localizeVersion = require('../../ng-snapshot/package.json').dependencies['@angular/localize'];
}
await npm('install', `${localizeVersion}`);
await installPackage(localizeVersion);

// Ensure a ES2015 build is used.
await writeFile('.browserslistrc', 'Chrome 65');
Expand Down
6 changes: 3 additions & 3 deletions tests/legacy-cli/e2e/tests/misc/common-async.ts
@@ -1,7 +1,7 @@
import {readdirSync} from 'fs';
import {oneLine} from 'common-tags';

import {ng, silentNpm} from '../../utils/process';
import { installPackage } from '../../utils/packages';
import { ng } from '../../utils/process';
import {appendToFile, expectFileToExist, prependToFile, replaceInFile} from '../../utils/fs';
import {expectToFail} from '../../utils/utils';

Expand Down Expand Up @@ -32,7 +32,7 @@ export default function() {
}
oldNumberOfFiles = currentNumberOfDistFiles;
})
.then(() => silentNpm('install', 'moment'))
.then(() => installPackage('moment'))
.then(() => appendToFile('src/app/lazy-a/lazy-a.module.ts', `
import * as moment from 'moment';
console.log(moment);
Expand Down
5 changes: 3 additions & 2 deletions tests/legacy-cli/e2e/tests/misc/dedupe-duplicate-modules.ts
@@ -1,5 +1,6 @@
import { expectFileToMatch, writeFile } from '../../utils/fs';
import { ng, silentNpm } from '../../utils/process';
import { installWorkspacePackages } from '../../utils/packages';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';

Expand All @@ -14,7 +15,7 @@ export default async function () {
};
});

await silentNpm('install');
await installWorkspacePackages();

await writeFile('./src/main.ts',
`
Expand Down