refactor(docs-infra): tidy up systemjs boilerplate for upgrade examples (#41689)
The ngUpgrade examples mostly rely upon SystemJS configuration. This commit tidies up how these examples are built and tested so that it will be easier to migrate them to work with Angular 11.2.x PR Close #41689
This commit is contained in:
parent
e06f1960f4
commit
1573510187
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"lib": [
|
||||
"es2015",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"skipLibCheck": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
},
|
||||
"compileOnSave": true,
|
||||
"exclude": [
|
||||
"node_modules/*",
|
||||
"**/*-aot.ts",
|
||||
"aot/**/*"
|
||||
]
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"lib": [
|
||||
"es2015",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"skipLibCheck": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
},
|
||||
"compileOnSave": true,
|
||||
"exclude": [
|
||||
"node_modules/*",
|
||||
"**/*-aot.ts"
|
||||
]
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"lib": [
|
||||
"es2015",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"skipLibCheck": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
},
|
||||
"compileOnSave": true,
|
||||
"exclude": [
|
||||
"node_modules/*",
|
||||
"**/*-aot.ts"
|
||||
]
|
||||
}
|
|
@ -118,12 +118,10 @@ This will be picked up by the default testing command (see the [example configur
|
|||
If you are using a custom test command, make sure e2e specs are picked up (if applicable).
|
||||
|
||||
For SystemJS-based examples, create an `e2e-spec.ts` file inside the example root folder.
|
||||
These apps will be tested with the following command:
|
||||
These apps will be tested with the following command (and an optional `outputFile` to receive log messages):
|
||||
|
||||
```sh
|
||||
yarn protractor aio/tools/examples/shared/protractor.config.js \
|
||||
--specs=<example-folder>/e2e-spec.ts \
|
||||
--params.appDir=<example-folder>
|
||||
yarn protractor [--params.outputFile=path/to/logfile.txt]
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -13,9 +13,7 @@ shelljs.set('-e');
|
|||
process.env.CHROME_BIN = require('puppeteer').executablePath();
|
||||
|
||||
const AIO_PATH = path.join(__dirname, '../../');
|
||||
const SHARED_PATH = path.join(__dirname, '/shared');
|
||||
const EXAMPLES_PATH = path.join(AIO_PATH, './content/examples/');
|
||||
const PROTRACTOR_CONFIG_FILENAME = path.join(__dirname, './shared/protractor.config.js');
|
||||
const SJS_SPEC_FILENAME = 'e2e-spec.ts';
|
||||
const CLI_SPEC_FILENAME = 'e2e/src/app.e2e-spec.ts';
|
||||
const EXAMPLE_CONFIG_FILENAME = 'example-config.json';
|
||||
|
@ -194,13 +192,7 @@ function runProtractorSystemJS(prepPromise, appDir, appRunSpawnInfo, outputFile)
|
|||
|
||||
// Start protractor.
|
||||
console.log(`\n\n=========== Running aio example tests for: ${appDir}`);
|
||||
const spawnInfo = spawnExt(
|
||||
'yarn',
|
||||
[
|
||||
'protractor', PROTRACTOR_CONFIG_FILENAME, `--specs=${specFilename}`,
|
||||
'--params.appDir=' + appDir, '--params.outputFile=' + outputFile
|
||||
],
|
||||
{cwd: SHARED_PATH});
|
||||
const spawnInfo = spawnExt('yarn', [ 'protractor', '--params.outputFile=' + outputFile ], {cwd: appDir});
|
||||
|
||||
spawnInfo.proc.stderr.on('data', function(data) {
|
||||
transpileError = transpileError || /npm ERR! Exit status 100/.test(data.toString());
|
||||
|
|
|
@ -4,16 +4,14 @@
|
|||
"description": "Example project from an angular.io guide.",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "tsc -p src/",
|
||||
"build:watch": "tsc -p src/ -w",
|
||||
"build:e2e": "tsc -p e2e/",
|
||||
"build": "tsc",
|
||||
"build:watch": "tsc -w",
|
||||
"serve": "lite-server -c=bs-config.json",
|
||||
"serve:e2e": "lite-server -c=bs-config.e2e.json",
|
||||
"prestart": "npm run build",
|
||||
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
|
||||
"pree2e": "webdriver-manager update && npm run build:e2e",
|
||||
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
|
||||
"protractor": "protractor protractor.config.js",
|
||||
"protractor": "protractor protractor.config.js --specs=e2e-spec.ts",
|
||||
"pretest": "npm run build",
|
||||
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
|
||||
"pretest:once": "npm run build",
|
||||
|
|
|
@ -49,7 +49,7 @@ exports.config = {
|
|||
// debugging
|
||||
// console.log('browser.params:' + JSON.stringify(browser.params));
|
||||
|
||||
jasmine.getEnv().addReporter(new Reporter( browser.params ));
|
||||
jasmine.getEnv().addReporter(new Reporter(browser.params.outputFile));
|
||||
},
|
||||
|
||||
jasmineNodeOpts: {
|
||||
|
@ -68,12 +68,8 @@ exports.config = {
|
|||
};
|
||||
|
||||
// See https://jasmine.github.io/2.1/custom_reporter.html
|
||||
function Reporter(options) {
|
||||
var _defaultOutputFile = path.resolve(__dirname, '../../protractor-results.txt');
|
||||
options.outputFile = options.outputFile || _defaultOutputFile;
|
||||
|
||||
var _root = { appDir: options.appDir, suites: [] };
|
||||
log('AppDir: ' + options.appDir, +1);
|
||||
function Reporter(outputFile) {
|
||||
var _root = { suites: [] };
|
||||
var _currentSuite;
|
||||
|
||||
this.suiteStarted = function(suite) {
|
||||
|
@ -114,21 +110,18 @@ function Reporter(options) {
|
|||
}
|
||||
};
|
||||
|
||||
this.jasmineDone = function() {
|
||||
outputFile = options.outputFile;
|
||||
//// Alternate approach - just stringify the _root - not as pretty
|
||||
//// but might be more useful for automation.
|
||||
// var output = JSON.stringify(_root, null, 2);
|
||||
var output = formatOutput(_root);
|
||||
fs.appendFileSync(outputFile, output);
|
||||
};
|
||||
if (outputFile) {
|
||||
this.jasmineDone = function() {
|
||||
var output = formatOutput(_root);
|
||||
fs.appendFileSync(outputFile, output);
|
||||
};
|
||||
}
|
||||
|
||||
// for output file output
|
||||
function formatOutput(output) {
|
||||
var indent = ' ';
|
||||
var pad = ' ';
|
||||
var results = [];
|
||||
results.push('AppDir:' + output.appDir);
|
||||
output.suites.forEach(function(suite) {
|
||||
results.push(pad + 'Suite: ' + suite.description + ' -- ' + suite.status);
|
||||
pad+=indent;
|
Loading…
Reference in New Issue