fix(build): test example directories with unit and e2e tests (#11296)
This commit is contained in:
parent
567900e550
commit
ed2ebeb52a
13
gulpfile.js
13
gulpfile.js
|
@ -142,6 +142,19 @@ gulp.task('serve', () => {
|
|||
});
|
||||
});
|
||||
|
||||
gulp.task('serve-examples', () => {
|
||||
let connect = require('gulp-connect');
|
||||
let cors = require('cors');
|
||||
|
||||
connect.server({
|
||||
root: `${__dirname}/dist/examples`,
|
||||
port: 8001,
|
||||
livereload: false,
|
||||
open: false,
|
||||
middleware: (connect, opt) => [cors()]
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
gulp.task('changelog', () => {
|
||||
const conventionalChangelog = require('gulp-conventional-changelog');
|
||||
|
|
|
@ -43,7 +43,8 @@ module.exports = function(config) {
|
|||
'dist/all/@angular/compiler-cli/**',
|
||||
'dist/all/@angular/benchpress/**',
|
||||
'dist/all/angular1_router.js',
|
||||
'dist/all/@angular/platform-browser/testing/e2e_util.js'
|
||||
'dist/all/@angular/platform-browser/testing/e2e_util.js',
|
||||
'dist/examples/**/e2e_test/**'
|
||||
],
|
||||
|
||||
customLaunchers: browserProvidersConf.customLaunchers,
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
(function(global: any) {
|
||||
writeScriptTag('/vendor/zone.js');
|
||||
writeScriptTag('/vendor/system.js');
|
||||
writeScriptTag('/vendor/Reflect.js');
|
||||
writeScriptTag('/_common/system-config.js');
|
||||
|
||||
function writeScriptTag(scriptUrl: string, onload: string = '') {
|
||||
document.write('<script src="' + scriptUrl + '" onload="' + onload + '"></script>');
|
||||
}
|
||||
}(window));
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import * as webdriver from 'selenium-webdriver';
|
||||
declare var browser: any;
|
||||
declare var expect: any;
|
||||
|
||||
// TODO (juliemr): remove this method once this becomes a protractor plugin
|
||||
export function verifyNoBrowserErrors() {
|
||||
browser.manage().logs().get('browser').then(function(browserLog) {
|
||||
var errors: any[] = [];
|
||||
browserLog.filter(logEntry => {
|
||||
var msg = logEntry.message;
|
||||
console.log('>> ' + msg);
|
||||
if (logEntry.level.value >= webdriver.logging.Level.INFO.value) {
|
||||
errors.push(msg);
|
||||
}
|
||||
});
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="bootstrap.js"></script>
|
||||
<script type="text/javascript">
|
||||
System.import('main-dynamic').catch(console.error.bind(console));
|
||||
</script>
|
||||
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<example-app>
|
||||
loading...
|
||||
</example-app>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||
import {AppModule} from './module';
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
DO NOT DELETE THIS FILE
|
||||
=======================
|
||||
|
||||
The purpose of this file is to allow `main-dynamic.ts` to be tsc-compiled
|
||||
BEFORE it is copied over to each of the associated example directories
|
||||
within `dist/examples`.
|
||||
|
||||
*/
|
||||
export class AppModule {};
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
System.config({
|
||||
defaultJSExtensions: true,
|
||||
map: {
|
||||
'@angular/common': '/vendor/@angular/common/bundles/common.umd.js',
|
||||
'@angular/compiler': '/vendor/@angular/compiler/bundles/compiler.umd.js',
|
||||
'@angular/core': '/vendor/@angular/core/bundles/core.umd.js',
|
||||
'@angular/forms': '/vendor/@angular/forms/bundles/forms.umd.js',
|
||||
'@angular/http': '/vendor/@angular/forms/bundles/http.umd.js',
|
||||
'@angular/platform-browser':
|
||||
'/vendor/@angular/platform-browser/bundles/platform-browser.umd.js',
|
||||
'@angular/platform-browser-dynamic':
|
||||
'/vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
|
||||
'@angular/router': '/vendor/@angular/router/bundles/router.umd.js',
|
||||
'@angular/upgrade': '/vendor/@angular/upgrade/bundles/upgrade.umd.js',
|
||||
'rxjs': '/vendor/rxjs',
|
||||
},
|
||||
packages: {
|
||||
// rxjs: {format: 'cjs', exports: 'Rx' }
|
||||
rxjs: {defaultExtension: 'js'}
|
||||
}
|
||||
});
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# This script is used to compile and copy the contents for each of
|
||||
# example directories over to the dist/examples directory so that they
|
||||
# can be tested with karma and protractor. The `gulp serve-examples` command
|
||||
# can be used to run each of the examples in isolation via http as well.
|
||||
#
|
||||
|
||||
cd `dirname $0`
|
||||
|
||||
DIST="../../../dist/examples";
|
||||
rm -rf -- $DIST
|
||||
$(npm bin)/tsc -p .
|
||||
|
||||
mkdir $DIST/vendor/
|
||||
|
||||
ln -s ../../../dist/packages-dist/ $DIST/vendor/@angular
|
||||
|
||||
for FILE in \
|
||||
../../../node_modules/zone.js/dist/zone.js \
|
||||
../../../node_modules/systemjs/dist/system.js \
|
||||
../../../node_modules/reflect-metadata/Reflect.js \
|
||||
../../../node_modules/rxjs
|
||||
do
|
||||
ln -s $FILE $DIST/vendor/`basename $FILE`
|
||||
done
|
||||
|
||||
for MODULE in `find . -name module.ts`; do
|
||||
FINAL_DIR_PATH=$DIST/`dirname $MODULE`
|
||||
|
||||
echo "==== $MODULE"
|
||||
cp _common/*.html $FINAL_DIR_PATH
|
||||
cp $DIST/_common/*.js $FINAL_DIR_PATH
|
||||
cp $DIST/_common/*.js.map $FINAL_DIR_PATH
|
||||
done
|
|
@ -7,10 +7,11 @@
|
|||
*/
|
||||
|
||||
// #docregion Component
|
||||
import {Component, animate, state, style, transition, trigger} from '@angular/core';
|
||||
import {Component, NgModule, animate, state, style, transition, trigger} from '@angular/core';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
|
||||
@Component({
|
||||
selector: 'my-expando',
|
||||
selector: 'example-app',
|
||||
styles: [`
|
||||
.toggle-container {
|
||||
background-color:white;
|
||||
|
@ -46,4 +47,9 @@ export class MyExpandoCmp {
|
|||
expand() { this.stateExpression = 'expanded'; }
|
||||
collapse() { this.stateExpression = 'collapsed'; }
|
||||
}
|
||||
|
||||
@NgModule({imports: [BrowserModule], declarations: [MyExpandoCmp], bootstrap: [MyExpandoCmp]})
|
||||
export class AppModule {
|
||||
}
|
||||
|
||||
// #enddocregion
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../../../_common/e2e_util';
|
||||
|
||||
function waitForElement(selector: string) {
|
||||
var EC = (<any>protractor).ExpectedConditions;
|
||||
// Waits for the element with id 'abc' to be present on the dom.
|
||||
browser.wait(EC.presenceOf($(selector)), 20000);
|
||||
}
|
||||
|
||||
describe('animation example', () => {
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
describe('index view', () => {
|
||||
var URL = '/core/animation/ts/dsl/index.html';
|
||||
|
||||
it('should list out the current collection of items', () => {
|
||||
browser.get(URL);
|
||||
waitForElement('.toggle-container');
|
||||
expect(element.all(by.css('.toggle-container')).get(0).getText()).toEqual('Look at this box');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
export {AppModule} from './animation_example';
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd `dirname $0`
|
||||
./build.sh
|
||||
|
||||
gulp serve-examples &
|
||||
|
||||
(cd ../../../ && NODE_PATH=$NODE_PATH:dist/all $(npm bin)/protractor protractor-examples-e2e.conf.js --bundles=true)
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"stripInternal": true,
|
||||
"experimentalDecorators": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../../../dist/examples",
|
||||
"paths": {
|
||||
"@angular/*": ["../../../dist/packages-dist/*"],
|
||||
"rxjs/*": ["../../../node_modules/rxjs/*"]
|
||||
},
|
||||
"rootDir": ".",
|
||||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"target": "es5",
|
||||
"lib": ["es2015", "dom"],
|
||||
"skipLibCheck": true,
|
||||
"types": ["jasmine", "protractor", "node"]
|
||||
},
|
||||
"include": [
|
||||
"./_common/*.ts",
|
||||
"./**/module.ts",
|
||||
"./**/test/*.ts",
|
||||
"./**/e2e_test/*.ts",
|
||||
"../../../node_modules/zone.js/dist/zone.js.d.ts",
|
||||
"../../system.d.ts"
|
||||
]
|
||||
}
|
|
@ -30,6 +30,7 @@
|
|||
"benchmarks_external",
|
||||
"payload_tests",
|
||||
"rollup-test",
|
||||
"@angular/examples/**/*.ts",
|
||||
"@angular/compiler-cli/integrationtest"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ exports.config = {
|
|||
'dist/all/**/e2e_test/**/*_spec.js'
|
||||
],
|
||||
exclude: [
|
||||
'dist/all/@angular/examples/**',
|
||||
'**/key_events/**', // can't tell why this is failing
|
||||
'**/sourcemap/**' // fails only on travis
|
||||
],
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
// Make sure that the command line is read as the first thing
|
||||
// as this could exit node if the help script should be printed.
|
||||
require('./dist/all/e2e_util/e2e_util').readCommandLine();
|
||||
|
||||
var BROWSER_OPTIONS = {
|
||||
LocalChrome: {
|
||||
'browserName': 'chrome'
|
||||
},
|
||||
ChromeOnTravis: {
|
||||
browserName: 'chrome',
|
||||
chromeOptions: {
|
||||
'args': ['--no-sandbox'],
|
||||
'binary': process.env.CHROME_BIN
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.config = {
|
||||
onPrepare: function() {
|
||||
beforeEach(function() {
|
||||
browser.ignoreSynchronization = false;
|
||||
});
|
||||
},
|
||||
allScriptsTimeout: 11000,
|
||||
specs: [
|
||||
'dist/examples/**/e2e_test/*_spec.js'
|
||||
],
|
||||
capabilities: process.env.TRAVIS ? BROWSER_OPTIONS.ChromeOnTravis : BROWSER_OPTIONS.LocalChrome,
|
||||
directConnect: true,
|
||||
baseUrl: 'http://localhost:8001/',
|
||||
framework: 'jasmine2',
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 60000,
|
||||
print: function(msg) { console.log(msg)}
|
||||
},
|
||||
useAllAngular2AppRoots: true
|
||||
};
|
|
@ -31,11 +31,13 @@ $(npm bin)/gulp check-cycle
|
|||
echo 'travis_fold:start:test.e2e.localChrome'
|
||||
cd dist/
|
||||
$(npm bin)/gulp serve &
|
||||
$(npm bin)/gulp serve-examples &
|
||||
cd ..
|
||||
if [[ ${TRAVIS} ]]; then
|
||||
sh -e /etc/init.d/xvfb start
|
||||
fi
|
||||
NODE_PATH=$NODE_PATH:./dist/all $(npm bin)/protractor ./protractor-e2e.conf.js --bundles=true
|
||||
NODE_PATH=$NODE_PATH:./dist/all $(npm bin)/protractor ./protractor-examples-e2e.conf.js --bundles=true
|
||||
NODE_PATH=$NODE_PATH:./dist/all $(npm bin)/protractor ./protractor-perf.conf.js --bundles=true --dryrun
|
||||
echo 'travis_fold:end:test.e2e.localChrome'
|
||||
|
||||
|
|
Loading…
Reference in New Issue