2016-10-04 23:39:20 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2016-10-04 23:39:20 -04:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2018-07-06 02:13:25 -04:00
|
|
|
const browserProvidersConf = require('./browser-providers.conf');
|
|
|
|
const {generateSeed} = require('./tools/jasmine-seed-generator');
|
2015-06-02 10:29:09 -04:00
|
|
|
|
2014-09-25 17:04:46 -04:00
|
|
|
// Karma configuration
|
|
|
|
// Generated on Thu Sep 25 2014 11:52:02 GMT-0700 (PDT)
|
|
|
|
module.exports = function(config) {
|
2018-12-18 01:09:39 -05:00
|
|
|
const conf = {
|
2014-09-25 17:04:46 -04:00
|
|
|
frameworks: ['jasmine'],
|
|
|
|
|
2018-07-06 02:13:25 -04:00
|
|
|
client: {
|
|
|
|
jasmine: {
|
|
|
|
random: true,
|
|
|
|
seed: generateSeed('karma-js.conf'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2014-09-25 17:04:46 -04:00
|
|
|
files: [
|
2014-10-06 20:35:00 -04:00
|
|
|
// Sources and specs.
|
2015-08-20 11:05:05 -04:00
|
|
|
// Loaded through the System loader, in `test-main.js`.
|
2016-04-28 20:50:03 -04:00
|
|
|
{pattern: 'dist/all/@angular/**/*.js', included: false, watched: true},
|
2014-10-06 20:35:00 -04:00
|
|
|
|
2018-02-15 12:21:18 -05:00
|
|
|
// Serve AngularJS for `ngUpgrade` testing.
|
2018-12-17 12:28:06 -05:00
|
|
|
{pattern: 'node_modules/angular-1.5/angular?(.min).js', included: false, watched: false},
|
2018-02-15 12:21:18 -05:00
|
|
|
{pattern: 'node_modules/angular-mocks-1.5/angular-mocks.js', included: false, watched: false},
|
2018-12-17 12:28:06 -05:00
|
|
|
{pattern: 'node_modules/angular-1.6/angular?(.min).js', included: false, watched: false},
|
2018-07-31 08:10:13 -04:00
|
|
|
{pattern: 'node_modules/angular-mocks-1.6/angular-mocks.js', included: false, watched: false},
|
2018-12-17 12:28:06 -05:00
|
|
|
{pattern: 'node_modules/angular/angular?(.min).js', included: false, watched: false},
|
2018-02-15 12:21:18 -05:00
|
|
|
{pattern: 'node_modules/angular-mocks/angular-mocks.js', included: false, watched: false},
|
2016-12-16 18:14:16 -05:00
|
|
|
|
2018-02-15 12:21:18 -05:00
|
|
|
'node_modules/core-js/client/core.js',
|
2020-06-12 12:25:08 -04:00
|
|
|
'node_modules/jasmine-ajax/lib/mock-ajax.js',
|
fix(core): detect DI parameters in JIT mode for downleveled ES2015 classes (#38463)
In the Angular Package Format, we always shipped UMD bundles and previously even ES5 module output.
With V10, we removed the ES5 module output but kept the UMD ES5 output.
For this, we were able to remove our second TypeScript transpilation. Instead we started only
building ES2015 output and then downleveled it to ES5 UMD for the NPM packages. This worked
as expected but unveiled an issue in the `@angular/core` reflection capabilities.
In JIT mode, Angular determines constructor parameters (for DI) using the `ReflectionCapabilities`. The
reflection capabilities basically read runtime metadata of classes to determine the DI parameters. Such
metadata can be either stored in static class properties like `ctorParameters` or within TypeScript's `design:params`.
If Angular comes across a class that does not have any parameter metadata, it tries to detect if the
given class is actually delegating to an inherited class. It does this naively in JIT by checking if the
stringified class (function in ES5) matches a certain pattern. e.g.
```js
function MatTable() {
var _this = _super.apply(this, arguments) || this;
```
These patterns are reluctant to changes of the class output. If a class is not recognized properly, the
DI parameters will be assumed empty and the class is **incorrectly** constructed without arguments.
This actually happened as part of v10 now. Since we downlevel ES2015 to ES5 (instead of previously
compiling sources directly to ES5), the class output changed slightly so that Angular no longer detects
it. e.g.
```js
var _this = _super.apply(this, __spread(arguments)) || this;
```
This happens because the ES2015 output will receive an auto-generated constructor if the class
defines class properties. This constructor is then already containing an explicit `super` call.
```js
export class MatTable extends CdkTable {
constructor() {
super(...arguments);
this.disabled = true;
}
}
```
If we then downlevel this file to ES5 with `--downlevelIteration`, TypeScript adjusts the `super` call so that
the spread operator is no longer used (not supported in ES5). The resulting super call is different to the
super call that would have been emitted if we would directly transpile to ES5. Ultimately, Angular no
longer detects such classes as having an delegate constructor -> and DI breaks.
We fix this by expanding the rather naive RegExp patterns used for the reflection capabilities
so that downleveled pass-through/delegate constructors are properly detected. There is a risk
of a false-positive as we cannot detect whether `__spread` is actually the TypeScript spread
helper, but given the reflection patterns already make lots of assumptions (e.g. that `super` is
actually the superclass, we should be fine making this assumption too. The false-positive would
not result in a broken app, but rather in unnecessary providers being injected (as a noop).
Fixes #38453
PR Close #38463
2020-08-14 04:23:53 -04:00
|
|
|
|
|
|
|
// Dependencies built by Bazel. See `config.yml` for steps running before
|
|
|
|
// the legacy Saucelabs tests run.
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#36540)
Close #35157
In the current version of zone.js, zone.js uses it's own package format, and it is not following the rule
of Angualr package format(APF), so it is not easily to be consumed by Angular CLI or other bundle tools.
For example, zone.js npm package has two bundles,
1. zone.js/dist/zone.js, this is a `es5` bundle.
2. zone.js/dist/zone-evergreen.js, this is a `es2015` bundle.
And Angular CLI has to add some hard-coding code to handle this case, ohttps://github.com/angular/angular-cli/blob/5376a8b1392ac7bd252782d8474161ce03a4d1cb/packages/schematics/angular/application/files/src/polyfills.ts.template#L55-L58
This PR upgrade zone.js npm package format to follow APF rule, https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#heading=h.k0mh3o8u5hx
The updated points are:
1. in package.json, update all bundle related properties
```
"main": "./bundles/zone.umd.js",
"module": "./fesm2015/zone.js",
"es2015": "./fesm2015/zone.js",
"fesm2015": "./fesm2015/zone.js",
```
2. re-organize dist folder, for example for `zone.js` bundle, now we have
```
dist/
bundles/
zone.js // this is the es5 bundle
fesm2015/
zone.js // this is the es2015 bundle (in the old version is `zone-evergreen.js`)
```
3. have several sub-packages.
1. `zone-testing`, provide zone-testing bundles include zone.js and testing libraries
2. `zone-node`, provide zone.js implemention for NodeJS
3. `zone-mix`, provide zone.js patches for both Browser and NodeJS
All those sub-packages will have their own `package.json` and the bundle will reference `bundles(es5)` and `fesm2015(es2015)`.
4. keep backward compatibility, still keep the `zone.js/dist` folder, and all bundles will be redirected to `zone.js/bundles` or `zone.js/fesm2015` folders.
PR Close #36540
2020-05-16 21:53:03 -04:00
|
|
|
'dist/bin/packages/zone.js/npm_package/bundles/zone.umd.js',
|
|
|
|
'dist/bin/packages/zone.js/npm_package/bundles/zone-testing.umd.js',
|
|
|
|
'dist/bin/packages/zone.js/npm_package/bundles/task-tracking.umd.js',
|
2015-08-05 13:32:14 -04:00
|
|
|
|
2014-10-30 13:52:32 -04:00
|
|
|
// Including systemjs because it defines `__eval`, which produces correct stack traces.
|
2017-09-01 13:30:37 -04:00
|
|
|
'test-events.js',
|
2020-06-17 08:34:41 -04:00
|
|
|
'third_party/shims_for_IE.js',
|
2016-12-16 18:14:16 -05:00
|
|
|
'node_modules/systemjs/dist/system.src.js',
|
2018-02-28 12:45:11 -05:00
|
|
|
|
|
|
|
// Serve polyfills necessary for testing the `elements` package.
|
|
|
|
{
|
|
|
|
pattern: 'node_modules/@webcomponents/custom-elements/**/*.js',
|
|
|
|
included: false,
|
|
|
|
watched: false
|
|
|
|
},
|
|
|
|
{pattern: 'node_modules/mutation-observer/index.js', included: false, watched: false},
|
|
|
|
|
2015-11-30 20:22:52 -05:00
|
|
|
{pattern: 'node_modules/rxjs/**', included: false, watched: false, served: true},
|
2016-12-16 18:14:16 -05:00
|
|
|
'node_modules/reflect-metadata/Reflect.js',
|
|
|
|
'tools/build/file2modulename.js',
|
|
|
|
'test-main.js',
|
2017-03-15 16:40:24 -04:00
|
|
|
{pattern: 'dist/all/@angular/empty.*', included: false, watched: false},
|
2017-03-07 14:04:30 -05:00
|
|
|
{pattern: 'packages/platform-browser/test/static_assets/**', included: false, watched: false},
|
2016-12-16 18:14:16 -05:00
|
|
|
{
|
2017-03-07 14:04:30 -05:00
|
|
|
pattern: 'packages/platform-browser/test/browser/static_assets/**',
|
2016-10-04 23:39:20 -04:00
|
|
|
included: false,
|
|
|
|
watched: false,
|
2017-07-20 04:54:07 -04:00
|
|
|
},
|
2014-09-25 17:04:46 -04:00
|
|
|
],
|
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
exclude: [
|
2017-12-16 14:35:47 -05:00
|
|
|
'dist/all/@angular/_testing_init/**',
|
2016-04-28 20:50:03 -04:00
|
|
|
'dist/all/@angular/**/e2e_test/**',
|
2016-12-12 13:49:17 -05:00
|
|
|
'dist/all/@angular/**/*node_only_spec.js',
|
2016-09-09 19:54:26 -04:00
|
|
|
'dist/all/@angular/benchpress/**',
|
2016-06-02 14:33:53 -04:00
|
|
|
'dist/all/@angular/compiler-cli/**',
|
2018-04-06 12:53:10 -04:00
|
|
|
'dist/all/@angular/compiler-cli/src/ngtsc/**',
|
2018-07-12 18:10:55 -04:00
|
|
|
'dist/all/@angular/compiler-cli/test/compliance/**',
|
2018-04-06 12:53:10 -04:00
|
|
|
'dist/all/@angular/compiler-cli/test/ngtsc/**',
|
2016-11-14 20:37:47 -05:00
|
|
|
'dist/all/@angular/compiler/test/aot/**',
|
2017-11-20 13:21:17 -05:00
|
|
|
'dist/all/@angular/compiler/test/render3/**',
|
2018-02-02 18:25:33 -05:00
|
|
|
'dist/all/@angular/core/test/bundling/**',
|
2018-07-13 04:51:54 -04:00
|
|
|
'dist/all/@angular/core/test/render3/ivy/**',
|
2019-10-24 23:28:11 -04:00
|
|
|
'dist/all/@angular/core/test/render3/perf/**',
|
2018-04-03 17:52:33 -04:00
|
|
|
'dist/all/@angular/elements/schematics/**',
|
2016-09-09 19:54:26 -04:00
|
|
|
'dist/all/@angular/examples/**/e2e_test/*',
|
2016-11-22 12:10:23 -05:00
|
|
|
'dist/all/@angular/language-service/**',
|
2019-07-30 13:02:17 -04:00
|
|
|
'dist/all/@angular/localize/**/test/**',
|
2019-09-20 11:05:45 -04:00
|
|
|
'dist/all/@angular/localize/schematics/**',
|
2017-11-07 12:21:48 -05:00
|
|
|
'dist/all/@angular/router/**/test/**',
|
2016-09-07 19:04:33 -04:00
|
|
|
'dist/all/@angular/platform-browser/testing/e2e_util.js',
|
2016-10-04 23:39:20 -04:00
|
|
|
'dist/examples/**/e2e_test/**',
|
2016-04-28 20:50:03 -04:00
|
|
|
],
|
2015-01-08 13:02:23 -05:00
|
|
|
|
2015-10-27 11:09:09 -04:00
|
|
|
customLaunchers: browserProvidersConf.customLaunchers,
|
2015-06-02 10:29:09 -04:00
|
|
|
|
2015-11-23 17:58:18 -05:00
|
|
|
plugins: [
|
|
|
|
'karma-jasmine',
|
|
|
|
'karma-browserstack-launcher',
|
|
|
|
'karma-sauce-launcher',
|
|
|
|
'karma-chrome-launcher',
|
|
|
|
'karma-sourcemap-loader',
|
|
|
|
],
|
|
|
|
|
|
|
|
preprocessors: {
|
2016-10-04 23:39:20 -04:00
|
|
|
'**/*.js': ['sourcemap'],
|
2015-11-23 17:58:18 -05:00
|
|
|
},
|
|
|
|
|
2018-05-31 02:49:37 -04:00
|
|
|
// Bazel inter-op: Allow tests to request resources from either
|
|
|
|
// /base/node_modules/path/to/thing
|
|
|
|
// or
|
|
|
|
// /base/angular/node_modules/path/to/thing
|
|
|
|
// This can be removed when all karma tests are run under Bazel, then we
|
|
|
|
// don't need this entire config file.
|
|
|
|
proxies: {
|
|
|
|
'/base/angular/': '/base/',
|
2019-02-20 12:54:42 -05:00
|
|
|
'/base/npm/': '/base/',
|
2018-05-31 02:49:37 -04:00
|
|
|
},
|
|
|
|
|
2015-06-02 10:29:09 -04:00
|
|
|
sauceLabs: {
|
|
|
|
testName: 'Angular2',
|
2016-04-28 20:50:03 -04:00
|
|
|
retryLimit: 3,
|
2015-06-02 10:29:09 -04:00
|
|
|
startConnect: false,
|
|
|
|
recordVideo: false,
|
|
|
|
recordScreenshots: false,
|
2018-12-12 17:07:21 -05:00
|
|
|
idleTimeout: 600,
|
|
|
|
commandTimeout: 600,
|
|
|
|
maxDuration: 5400,
|
2014-09-29 17:20:23 -04:00
|
|
|
},
|
2015-06-02 10:29:09 -04:00
|
|
|
|
2015-10-27 11:09:09 -04:00
|
|
|
browserStack: {
|
|
|
|
project: 'Angular2',
|
|
|
|
startTunnel: false,
|
2016-04-28 20:50:03 -04:00
|
|
|
retryLimit: 3,
|
2016-11-10 14:58:06 -05:00
|
|
|
timeout: 1800,
|
2016-10-04 23:39:20 -04:00
|
|
|
pollingTimeout: 10000,
|
2015-10-27 11:09:09 -04:00
|
|
|
},
|
|
|
|
|
2018-12-18 01:09:39 -05:00
|
|
|
// Try "websocket" for a faster transmission first. Fallback to "polling" if necessary.
|
|
|
|
transports: ['websocket', 'polling'],
|
2014-10-09 16:50:25 -04:00
|
|
|
|
2016-05-02 01:22:26 -04:00
|
|
|
port: 9876,
|
2016-11-10 14:58:06 -05:00
|
|
|
captureTimeout: 180000,
|
|
|
|
browserDisconnectTimeout: 180000,
|
2016-10-04 23:39:20 -04:00
|
|
|
browserDisconnectTolerance: 3,
|
2016-11-10 14:58:06 -05:00
|
|
|
browserNoActivityTimeout: 300000,
|
2019-12-12 04:39:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1431. The idea is
|
|
|
|
// that we do no not allow `@bazel/karma` to add the `progress` reporter.
|
|
|
|
Object.defineProperty(conf, 'reporters', {
|
|
|
|
enumerable: true,
|
|
|
|
get: () => ['dots'],
|
|
|
|
set: () => {},
|
|
|
|
});
|
2018-12-18 01:09:39 -05:00
|
|
|
|
|
|
|
if (process.env['SAUCE_TUNNEL_IDENTIFIER']) {
|
|
|
|
console.log(`SAUCE_TUNNEL_IDENTIFIER: ${process.env.SAUCE_TUNNEL_IDENTIFIER}`);
|
2015-06-02 10:29:09 -04:00
|
|
|
|
2019-01-04 14:58:33 -05:00
|
|
|
const tunnelIdentifier = process.env['SAUCE_TUNNEL_IDENTIFIER'];
|
|
|
|
|
|
|
|
// Setup the Saucelabs plugin so that it can launch browsers using the proper tunnel.
|
2018-12-18 01:09:39 -05:00
|
|
|
conf.sauceLabs.build = tunnelIdentifier;
|
|
|
|
conf.sauceLabs.tunnelIdentifier = tunnelIdentifier;
|
2019-01-04 14:58:33 -05:00
|
|
|
|
|
|
|
// Setup the Browserstack plugin so that it can launch browsers using the proper tunnel.
|
|
|
|
// TODO: This is currently not used because BS doesn't run on the CI. Consider removing.
|
2018-12-18 01:09:39 -05:00
|
|
|
conf.browserStack.build = tunnelIdentifier;
|
|
|
|
conf.browserStack.tunnelIdentifier = tunnelIdentifier;
|
|
|
|
}
|
2019-01-04 14:58:33 -05:00
|
|
|
|
2020-02-06 08:17:03 -05:00
|
|
|
// For SauceLabs jobs, we set up a domain which resolves to the machine which launched
|
|
|
|
// the tunnel. We do this because devices are sometimes not able to properly resolve
|
|
|
|
// `localhost` or `127.0.0.1` through the SauceLabs tunnel. Using a domain that does not
|
|
|
|
// resolve to anything on SauceLabs VMs ensures that such requests are always resolved through
|
|
|
|
// the tunnel, and resolve to the actual tunnel host machine (commonly the CircleCI VMs).
|
|
|
|
// More context can be found in: https://github.com/angular/angular/pull/35171.
|
|
|
|
if (process.env.SAUCE_LOCALHOST_ALIAS_DOMAIN) {
|
|
|
|
conf.hostname = process.env.SAUCE_LOCALHOST_ALIAS_DOMAIN;
|
|
|
|
}
|
|
|
|
|
2018-12-18 01:09:39 -05:00
|
|
|
if (process.env.KARMA_WEB_TEST_MODE) {
|
|
|
|
// KARMA_WEB_TEST_MODE is used to setup karma to run in
|
|
|
|
// SauceLabs or Browserstack
|
|
|
|
console.log(`KARMA_WEB_TEST_MODE: ${process.env.KARMA_WEB_TEST_MODE}`);
|
|
|
|
|
|
|
|
switch (process.env.KARMA_WEB_TEST_MODE) {
|
|
|
|
case 'SL_REQUIRED':
|
|
|
|
conf.browsers = browserProvidersConf.sauceAliases.CI_REQUIRED;
|
|
|
|
break;
|
|
|
|
case 'SL_OPTIONAL':
|
|
|
|
conf.browsers = browserProvidersConf.sauceAliases.CI_OPTIONAL;
|
|
|
|
break;
|
|
|
|
case 'BS_REQUIRED':
|
|
|
|
conf.browsers = browserProvidersConf.browserstackAliases.CI_REQUIRED;
|
|
|
|
break;
|
|
|
|
case 'BS_OPTIONAL':
|
|
|
|
conf.browsers = browserProvidersConf.browserstackAliases.CI_OPTIONAL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new Error(
|
|
|
|
`Unrecognized process.env.KARMA_WEB_TEST_MODE: ${process.env.KARMA_WEB_TEST_MODE}`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Run the test locally
|
|
|
|
conf.browsers = [process.env['DISPLAY'] ? 'Chrome' : 'ChromeHeadless'];
|
2015-06-02 10:29:09 -04:00
|
|
|
}
|
2018-12-18 01:09:39 -05:00
|
|
|
|
|
|
|
config.set(conf);
|
2014-09-25 17:04:46 -04:00
|
|
|
};
|