test: protractor test for closure bundle (#14240)

PR Close #14240
This commit is contained in:
Alex Eagle 2017-02-01 20:47:04 -08:00 committed by Miško Hevery
parent d0366542fb
commit e9a89c0693
10 changed files with 116 additions and 11 deletions

View File

@ -31,16 +31,18 @@ CLOSURE_ARGS=(
# Uncomment for easier debugging # Uncomment for easier debugging
# "--formatting=PRETTY_PRINT" # "--formatting=PRETTY_PRINT"
e2e/testability.externs.js
node_modules/zone.js/dist/zone.js node_modules/zone.js/dist/zone.js
$(find -L vendor/rxjs -name *.js) $(find -L vendor/rxjs -name *.js)
node_modules/@angular/{core,common,compiler,platform-browser}/index.js node_modules/@angular/{core,common,compiler,platform-browser}/index.js
$(find node_modules/@angular/{core,common,compiler,platform-browser}/src -name *.js) $(find node_modules/@angular/{core,common,compiler,platform-browser}/src -name *.js)
"built/*.js" "built/src/*.js"
"--entry_point=./built/main" "--entry_point=./built/src/main"
) )
java -jar node_modules/google-closure-compiler/compiler.jar $(echo ${CLOSURE_ARGS[*]}) java -jar node_modules/google-closure-compiler/compiler.jar $(echo ${CLOSURE_ARGS[*]})
# gzip on Travis doesn't have --keep option so copy the original file first
cp dist/bundle.js dist/bundle.tmp
gzip -f dist/bundle.js gzip -f dist/bundle.js
mv dist/bundle.tmp dist/bundle.js
ls -alH dist/bundle* ls -alH dist/bundle*
# TODO(alexeagle): add an e2e test that the application works in a browser

View File

@ -0,0 +1,8 @@
import { browser, element, by } from 'protractor';
describe('Hello world E2E Tests', function () {
it('should display: Hello world!', function () {
browser.get('');
expect(element(by.css('div')).getText()).toEqual('Hello world!');
});
});

View File

@ -0,0 +1,14 @@
{
"open": false,
"logLevel": "silent",
"port": 8080,
"server": {
"baseDir": "src",
"routes": {
"/dist": "dist"
},
"middleware": {
"0": null
}
}
}

View File

@ -0,0 +1,16 @@
exports.config = {
specs: [
'../built/e2e/*.e2e-spec.js'
],
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox'],
binary: process.env.CHROME_BIN,
}
},
directConnect: true,
baseUrl: 'http://localhost:8080/',
framework: 'jasmine',
useAllAngular2AppRoots: true
};

View File

@ -0,0 +1,47 @@
/** @externs */
// Workaround for #11119
// TODO(alexeagle): these externs ought to be distributed with Angular.
/**
* @externs
* @suppress {duplicate}
*/
// NOTE: generated by tsickle, do not edit.
/** @record @struct */
function BrowserNodeGlobal() {}
/** @type {?} */
BrowserNodeGlobal.prototype.getAngularTestability;
/** @type {?} */
BrowserNodeGlobal.prototype.getAllAngularTestabilities;
/** @type {?} */
BrowserNodeGlobal.prototype.getAllAngularRootElements;
/** @type {?} */
BrowserNodeGlobal.prototype.frameworkStabilizers;
/**
* @param {?} condition
* @return {?}
*/
BrowserNodeGlobal.prototype.assert = function(condition) {};
/** @record @struct */
function PublicTestability() {}
/**
* @return {?}
*/
PublicTestability.prototype.isStable = function() {};
/**
* @param {?} callback
* @return {?}
*/
PublicTestability.prototype.whenStable = function(callback) {};
/**
* @param {?} using
* @param {?} provider
* @param {?} exactMatch
* @return {?}
*/
PublicTestability.prototype.findProviders = function(using, provider, exactMatch) {};

View File

@ -0,0 +1,8 @@
{
"compilerOptions": {
"outDir": "../built/e2e",
"types": ["jasmine"],
// TODO(alexeagle): was required for Protractor 4.0.11
"skipLibCheck": true
}
}

View File

@ -16,7 +16,16 @@
"typescript": "~2.0", "typescript": "~2.0",
"zone.js": "^0.7.6" "zone.js": "^0.7.6"
}, },
"devDependencies": {
"@types/jasmine": "^2.5.41",
"concurrently": "^3.1.0",
"lite-server": "^2.2.2",
"protractor": "file:../../node_modules/protractor"
},
"scripts": { "scripts": {
"test": "ngc && ./build.sh" "test": "ngc && ./bundle.sh && concurrently \"npm run serve\" \"npm run protractor\" --kill-others --success first",
"serve": "lite-server -c e2e/browser.config.json",
"preprotractor": "tsc -p e2e",
"protractor": "protractor e2e/protractor.config.js"
} }
} }

View File

@ -8,7 +8,7 @@
<body> <body>
<hello-world-app>Loading...</hello-world-app> <hello-world-app>Loading...</hello-world-app>
<script src="../dist/bundle.js"></script> <script src="dist/bundle.js"></script>
</body> </body>
</html> </html>

View File

@ -11,7 +11,7 @@
"noImplicitAny": false, "noImplicitAny": false,
"sourceMap": false, "sourceMap": false,
"experimentalDecorators": true, "experimentalDecorators": true,
"outDir": "built", "outDir": "built/src",
"declaration": true, "declaration": true,
"types": [] "types": []
}, },
@ -21,6 +21,6 @@
"node_modules", "node_modules",
"built", "built",
"dist", "dist",
"src/main-jit.ts" "e2e"
] ]
} }

View File

@ -21,6 +21,10 @@ echo 'travis_fold:start:test.buildPackages'
echo 'travis_fold:end:test.buildPackages' echo 'travis_fold:end:test.buildPackages'
if [[ ${TRAVIS} ]]; then
sh -e /etc/init.d/xvfb start
fi
./integration/build_rxjs_es6.sh ./integration/build_rxjs_es6.sh
./integration/run_tests.sh ./integration/run_tests.sh
#TODO(alexeagle): move offline_compiler_test to integration/ #TODO(alexeagle): move offline_compiler_test to integration/
@ -35,9 +39,6 @@ cd dist/
$(npm bin)/gulp serve & $(npm bin)/gulp serve &
$(npm bin)/gulp serve-examples & $(npm bin)/gulp serve-examples &
cd .. 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-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-examples-e2e.conf.js --bundles=true
NODE_PATH=$NODE_PATH:./dist/all $(npm bin)/protractor ./protractor-perf.conf.js --bundles=true --dryrun NODE_PATH=$NODE_PATH:./dist/all $(npm bin)/protractor ./protractor-perf.conf.js --bundles=true --dryrun