diff --git a/integration/hello_world__closure/build.sh b/integration/hello_world__closure/bundle.sh similarity index 85% rename from integration/hello_world__closure/build.sh rename to integration/hello_world__closure/bundle.sh index 1143830985..03dec2970e 100755 --- a/integration/hello_world__closure/build.sh +++ b/integration/hello_world__closure/bundle.sh @@ -31,16 +31,18 @@ CLOSURE_ARGS=( # Uncomment for easier debugging # "--formatting=PRETTY_PRINT" + e2e/testability.externs.js node_modules/zone.js/dist/zone.js $(find -L vendor/rxjs -name *.js) node_modules/@angular/{core,common,compiler,platform-browser}/index.js $(find node_modules/@angular/{core,common,compiler,platform-browser}/src -name *.js) - "built/*.js" - "--entry_point=./built/main" + "built/src/*.js" + "--entry_point=./built/src/main" ) 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 +mv dist/bundle.tmp dist/bundle.js ls -alH dist/bundle* - -# TODO(alexeagle): add an e2e test that the application works in a browser diff --git a/integration/hello_world__closure/e2e/app.e2e-spec.ts b/integration/hello_world__closure/e2e/app.e2e-spec.ts new file mode 100644 index 0000000000..d23f09b6c2 --- /dev/null +++ b/integration/hello_world__closure/e2e/app.e2e-spec.ts @@ -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!'); + }); +}); diff --git a/integration/hello_world__closure/e2e/browser.config.json b/integration/hello_world__closure/e2e/browser.config.json new file mode 100644 index 0000000000..2886960214 --- /dev/null +++ b/integration/hello_world__closure/e2e/browser.config.json @@ -0,0 +1,14 @@ +{ + "open": false, + "logLevel": "silent", + "port": 8080, + "server": { + "baseDir": "src", + "routes": { + "/dist": "dist" + }, + "middleware": { + "0": null + } + } +} diff --git a/integration/hello_world__closure/e2e/protractor.config.js b/integration/hello_world__closure/e2e/protractor.config.js new file mode 100644 index 0000000000..5bc4f6e640 --- /dev/null +++ b/integration/hello_world__closure/e2e/protractor.config.js @@ -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 +}; diff --git a/integration/hello_world__closure/e2e/testability.externs.js b/integration/hello_world__closure/e2e/testability.externs.js new file mode 100644 index 0000000000..a17161d38e --- /dev/null +++ b/integration/hello_world__closure/e2e/testability.externs.js @@ -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) {}; \ No newline at end of file diff --git a/integration/hello_world__closure/e2e/tsconfig.json b/integration/hello_world__closure/e2e/tsconfig.json new file mode 100644 index 0000000000..e112859422 --- /dev/null +++ b/integration/hello_world__closure/e2e/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "outDir": "../built/e2e", + "types": ["jasmine"], + // TODO(alexeagle): was required for Protractor 4.0.11 + "skipLibCheck": true + } +} \ No newline at end of file diff --git a/integration/hello_world__closure/package.json b/integration/hello_world__closure/package.json index 841ac415f5..f09cc3583c 100644 --- a/integration/hello_world__closure/package.json +++ b/integration/hello_world__closure/package.json @@ -16,7 +16,16 @@ "typescript": "~2.0", "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": { - "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" } } diff --git a/integration/hello_world__closure/src/index.html b/integration/hello_world__closure/src/index.html index c6754de79e..c2190cc743 100644 --- a/integration/hello_world__closure/src/index.html +++ b/integration/hello_world__closure/src/index.html @@ -8,7 +8,7 @@