-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
test(ivy): add render3 integration tests #21557
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
# This script replaces 'ngDevMode' by false in @angular/core/render3 source code, so that this code can be eliminated. | ||
# This is a workaround for https://github.com/google/closure-compiler/issues/1601 | ||
|
||
find built/packages/core/src/render3/* -name '*.js' -exec sed -i '' -e "s/import '.\/ng_dev_mode';//g" {} \; | ||
find built/packages/core/src/render3/* -name '*.js' -exec sed -i '' -e 's/ngDevMode/false/g' {} \; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--compilation_level=ADVANCED_OPTIMIZATIONS | ||
--language_out=ES5 | ||
--js_output_file=dist/bundle.js | ||
--output_manifest=dist/manifest.MF | ||
--variable_renaming_report=dist/variable_renaming_report | ||
--property_renaming_report=dist/property_renaming_report | ||
--create_source_map=%outname%.map | ||
|
||
--warning_level=QUIET | ||
--dependency_mode=STRICT | ||
--rewrite_polyfills=false | ||
--jscomp_off=checkVars | ||
|
||
--module_resolution=node | ||
--package_json_entry_names es2015 | ||
--process_common_js_modules | ||
|
||
--js built/**.js | ||
--entry_point=built/index | ||
|
||
--output_wrapper "%output% | ||
//# sourceMappingURL=bundle.js.map" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { browser, element, by } from 'protractor'; | ||
|
||
describe('Hello world E2E Tests', function () { | ||
it('should display: Hello world!', function () { | ||
browser.ignoreSynchronization = true; | ||
browser.get(''); | ||
const div = element(by.css('div')); | ||
expect(div.getText()).toEqual('Hello world!'); | ||
element(by.css('input')).sendKeys('!'); | ||
expect(div.getText()).toEqual('Hello world!!'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"open": false, | ||
"logLevel": "silent", | ||
"port": 8080, | ||
"server": { | ||
"baseDir": "src", | ||
"routes": { | ||
"/dist": "dist", | ||
"/node_modules": "node_modules" | ||
}, | ||
"middleware": { | ||
"0": null | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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' | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "../built/e2e", | ||
"types": ["jasmine"], | ||
// TODO(alexeagle): was required for Protractor 4.0.11 | ||
"skipLibCheck": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "angular-integration", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add "private: true" plz There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
"private": true, | ||
"dependencies": { | ||
"typescript": "file:../../node_modules/typescript" | ||
}, | ||
"devDependencies": { | ||
"@types/jasmine": "2.5.41", | ||
"concurrently": "3.4.0", | ||
"lite-server": "2.2.2", | ||
"protractor": "file:../../node_modules/protractor", | ||
"google-closure-compiler": "20171023.0.1" | ||
}, | ||
"scripts": { | ||
"postinstall": "webdriver-manager update --gecko false --standalone false $CHROMEDRIVER_VERSION_ARG && mkdir -p built && cp -rf ../../dist/packages ./built/packages && ./clean_ngDevMode.sh", | ||
"closure": "java -jar node_modules/google-closure-compiler/compiler.jar --flagfile closure.conf && mkdir -p dist/packages && cp -rf ../../packages/core dist/packages/core", | ||
"test": "tsc && yarn run closure && concurrently \"yarn run serve\" \"yarn run protractor\" --kill-others --success first", | ||
"serve": "lite-server -c e2e/browser.config.json", | ||
"preprotractor": "tsc -p e2e", | ||
"protractor": "protractor e2e/protractor.config.js" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!doctype html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Hello World</title> | ||
<base href="/"> | ||
</head> | ||
|
||
<body> | ||
<hello-world></hello-world> | ||
|
||
<script src="dist/bundle.js"></script> | ||
|
||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @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 {defineComponent, renderComponent, detectChanges, T, t, E, e, L, p, b, b1} from '../built/packages/core/src/render3'; | ||
import {ComponentDef} from '../built/packages/core/src/render3/interfaces/definition'; | ||
|
||
export class HelloWorld { | ||
name: string = "world"; | ||
|
||
/** @nocollapse */ | ||
static ngComponentDef: ComponentDef<HelloWorld> = defineComponent({ | ||
tag: 'hello-world', | ||
template: function (ctx: HelloWorld, cm: boolean) { | ||
if (cm) { | ||
E(0, 'div'); | ||
T(1); | ||
e(); | ||
E(2, 'input'); | ||
L('input', (e) => { | ||
ctx.name = (<HTMLInputElement>e.target).value; | ||
detectChanges(component); | ||
}); | ||
e(); | ||
} | ||
t(1, b1('Hello ', ctx.name, '!')); | ||
p(2, 'value', b(ctx.name)); | ||
}, | ||
factory: () => new HelloWorld() | ||
}); | ||
} | ||
|
||
const component = renderComponent(HelloWorld); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"angularCompilerOptions": { | ||
"annotationsAs": "static fields", | ||
"annotateForClosureCompiler": true, | ||
"alwaysCompileGeneratedCode": true | ||
}, | ||
|
||
"compilerOptions": { | ||
"module": "es2015", | ||
"moduleResolution": "node", | ||
"strict": true, | ||
"target": "es5", | ||
"noImplicitAny": false, | ||
"sourceMap": false, | ||
"experimentalDecorators": true, | ||
"outDir": "built", | ||
"rootDir": "./src", | ||
"declaration": true, | ||
"types": [], | ||
"lib": ["es2015", "dom"] | ||
}, | ||
"files": [ | ||
"src/index.ts" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { browser, element, by } from 'protractor'; | ||
|
||
describe('Hello world E2E Tests', function () { | ||
it('should display: Hello world!', function () { | ||
browser.ignoreSynchronization = true; | ||
browser.get(''); | ||
const div = element(by.css('div')); | ||
expect(div.getText()).toEqual('Hello world!'); | ||
element(by.css('input')).sendKeys('!'); | ||
expect(div.getText()).toEqual('Hello world!!'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"open": false, | ||
"logLevel": "silent", | ||
"port": 8080, | ||
"server": { | ||
"baseDir": "src", | ||
"routes": { | ||
"/dist": "dist", | ||
"/node_modules": "node_modules" | ||
}, | ||
"middleware": { | ||
"0": null | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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' | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "../built/e2e", | ||
"types": ["jasmine"], | ||
// TODO(alexeagle): was required for Protractor 4.0.11 | ||
"skipLibCheck": true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "angular-integration", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. private true There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
"private": true, | ||
"dependencies": { | ||
"@angular/animations": "file:../../dist/packages-dist/animations", | ||
"@angular/common": "file:../../dist/packages-dist/common", | ||
"@angular/compiler": "file:../../dist/packages-dist/compiler", | ||
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli", | ||
"@angular/core": "file:../../dist/packages-dist/core", | ||
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser", | ||
"@angular/platform-server": "file:../../dist/packages-dist/platform-server", | ||
"rxjs": "file:../../node_modules/rxjs", | ||
"typescript": "file:../../node_modules/typescript" | ||
}, | ||
"devDependencies": { | ||
"@types/jasmine": "2.5.41", | ||
"concurrently": "3.4.0", | ||
"lite-server": "2.2.2", | ||
"protractor": "file:../../node_modules/protractor", | ||
"rollup": "0.54.0", | ||
"rollup-plugin-commonjs": "8.2.6", | ||
"rollup-plugin-node-resolve": "3.0.2", | ||
"rollup-plugin-replace": "2.0.0", | ||
"rollup-plugin-typescript2": "0.10.0", | ||
"rollup-plugin-uglify": "2.0.1" | ||
}, | ||
"scripts": { | ||
"postinstall": "webdriver-manager update --gecko false --standalone false $CHROMEDRIVER_VERSION_ARG", | ||
"rollup": "rollup -c rollup.config.js", | ||
"test": "yarn run rollup && concurrently \"yarn run serve\" \"yarn run protractor\" --kill-others --success first", | ||
"serve": "lite-server -c e2e/browser.config.json", | ||
"preprotractor": "tsc -p e2e", | ||
"protractor": "protractor e2e/protractor.config.js" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import nodeResolve from 'rollup-plugin-node-resolve'; | ||
import replace from 'rollup-plugin-replace'; | ||
import typescript2 from 'rollup-plugin-typescript2'; | ||
import uglify from 'rollup-plugin-uglify'; | ||
|
||
export default { | ||
input: `src/index.ts`, | ||
output: { | ||
name: 'hw', | ||
file: `dist/bundle.js`, | ||
format: 'iife', | ||
sourcemap: false | ||
}, | ||
plugins: [ | ||
typescript2({ | ||
typescript: require('typescript'), | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true | ||
}), | ||
replace({ | ||
delimiters: ['', ''], | ||
values: { | ||
'/** @class */': '/** @__PURE__ */' | ||
} | ||
}), | ||
nodeResolve({jsnext: true, module: true}), | ||
commonjs({ | ||
include: 'node_modules/rxjs/**', | ||
}), | ||
uglify({ | ||
mangle: true, | ||
compress: { | ||
global_defs: { | ||
'ngDevMode': false, | ||
} | ||
} | ||
}) | ||
], | ||
external: [] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!doctype html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Hello World</title> | ||
<base href="/"> | ||
</head> | ||
|
||
<body> | ||
<hello-world></hello-world> | ||
|
||
<script src="dist/bundle.js"></script> | ||
|
||
</body> | ||
|
||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you document what this does and why do we do it this way?
I thought closure had a way to set the compilation constant via config so I'm not sure why we do this kind of search&replace. if there is a good reason for it, please document it in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is workaround for google/closure-compiler#1601 Can you include the link in a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you see if you can get it work with
This should set the closure compiler vars and tree shake them, but I don't seem to be able to get it to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added. Due to this bug, I couldn't make it work either.