Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 2b6dedf

Browse files
committed
fix(test): karma-dist should test bundle under dist
1 parent 1ba8519 commit 2b6dedf

14 files changed

+151
-185
lines changed

gulpfile.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ function generateScript(inFile, outFile, minify, callback) {
4343
'rxjs/Observable': 'Rx',
4444
'rxjs/Subscriber': 'Rx',
4545
'rxjs/Subscription': 'Rx',
46+
'rxjs/Scheduler': 'Rx.Scheduler',
4647
'rxjs/scheduler/asap': 'Rx.Scheduler',
48+
'rxjs/scheduler/async': 'Rx.Scheduler',
4749
'rxjs/symbol/rxSubscriber': 'Rx.Symbol'
4850
}
4951
},
@@ -404,9 +406,9 @@ function nodeTest(specFiles, cb) {
404406
require('./build/lib/node/rollup-main');
405407
var args = process.argv;
406408
if (args.length > 3) {
407-
require('./build/test/test-env-setup-jasmine' + args[3]);
409+
require('./build/test/test-env-setup-jasmine' + args[3]);
408410
}
409-
var JasmineRunner = require('jasmine');
411+
var JasmineRunner = require('jasmine');
410412
var JasmineRunner = require('jasmine');
411413
var jrunner = new JasmineRunner();
412414

karma-base.conf.js

+12-18
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,39 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
module.exports = function (config) {
9+
module.exports = function(config) {
1010
config.set({
1111
basePath: '',
1212
files: [
13-
'node_modules/systemjs/dist/system-polyfills.js',
14-
'node_modules/systemjs/dist/system.src.js',
13+
'node_modules/systemjs/dist/system-polyfills.js', 'node_modules/systemjs/dist/system.src.js',
1514
'node_modules/whatwg-fetch/fetch.js',
16-
{pattern: 'node_modules/rxjs/**/**/*.js', included: false, watched: false },
17-
{pattern: 'node_modules/rxjs/**/**/*.js.map', included: false, watched: false },
18-
{pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
19-
{pattern: 'node_modules/es6-promise/**/*.js', included: false, watched: false },
20-
{pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
15+
{pattern: 'node_modules/rxjs/**/**/*.js', included: false, watched: false},
16+
{pattern: 'node_modules/rxjs/**/**/*.js.map', included: false, watched: false},
17+
{pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false},
18+
{pattern: 'node_modules/es6-promise/**/*.js', included: false, watched: false},
19+
{pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false},
2120
{pattern: 'test/assets/**/*.*', watched: true, served: true, included: false},
2221
{pattern: 'build/**/*.js.map', watched: true, served: true, included: false},
2322
{pattern: 'build/**/*.js', watched: true, served: true, included: false}
2423
],
2524

2625
plugins: [
27-
require('karma-chrome-launcher'),
28-
require('karma-firefox-launcher'),
26+
require('karma-chrome-launcher'), require('karma-firefox-launcher'),
2927
require('karma-sourcemap-loader')
3028
],
3129

32-
preprocessors: {
33-
'**/*.js': ['sourcemap']
34-
},
30+
preprocessors: {'**/*.js': ['sourcemap']},
3531

36-
exclude: [
37-
'test/microtasks.spec.ts'
38-
],
32+
exclude: ['test/microtasks.spec.ts'],
3933

4034
reporters: ['progress'],
4135

42-
//port: 9876,
36+
// port: 9876,
4337
colors: true,
4438

4539
logLevel: config.LOG_INFO,
4640

47-
browsers: ['Firefox'],
41+
browsers: ['Chrome'],
4842

4943
captureTimeout: 60000,
5044

karma-dist-mocha.conf.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11

2-
module.exports = function (config) {
2+
module.exports = function(config) {
33
require('./karma-dist.conf.js')(config);
44

5+
for (let i = 0; i < config.files.length; i++) {
6+
if (config.files[i] === 'dist/zone-testing.js') {
7+
config.files.splice(i, 1);
8+
break;
9+
}
10+
}
11+
config.files.push('dist/long-stack-trace-zone.js');
12+
config.files.push('dist/proxy.js');
13+
config.files.push('dist/sync-test.js');
14+
config.files.push('dist/async-test.js');
15+
config.files.push('dist/fake-async-test.js');
16+
config.files.push('dist/zone-patch-promise-test.js');
517
config.plugins.push(require('karma-mocha'));
618
config.frameworks.push('mocha');
719
config.client.mocha = {
8-
timeout: 5000 // copied timeout for Jasmine in WebSocket.spec (otherwise Mochas default timeout at 2 sec is to low for the tests)
20+
timeout: 5000 // copied timeout for Jasmine in WebSocket.spec (otherwise Mochas default timeout
21+
// at 2 sec is to low for the tests)
922
};
1023
};

karma-dist.conf.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@ module.exports = function(config) {
1212
config.files.push('build/test/test_fake_polyfill.js');
1313
config.files.push('build/test/custom_error.js');
1414
config.files.push('dist/zone.js');
15+
config.files.push('dist/webapis-media-query.js');
16+
config.files.push('dist/webapis-notification.js');
1517
config.files.push('dist/zone-patch-user-media.js');
1618
config.files.push('dist/zone-patch-resize-observer.js');
17-
config.files.push('dist/long-stack-trace-zone.js');
18-
config.files.push('dist/proxy.js');
19-
config.files.push('dist/sync-test.js');
20-
config.files.push('dist/async-test.js');
21-
config.files.push('dist/fake-async-test.js');
2219
config.files.push('dist/task-tracking.js');
23-
config.files.push('dist/zone-patch-promise-test.js');
2420
config.files.push('dist/wtf.js');
21+
config.files.push('dist/zone-testing.js');
2522
config.files.push('build/test/main.js');
2623
};

sauce-selenium3.conf.js

+13-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
// Sauce configuration with Welenium drivers 3+
22

3-
module.exports = function (config) {
3+
module.exports = function(config) {
44
// The WS server is not available with Sauce
55
config.files.unshift('test/saucelabs.js');
66

77
var customLaunchers = {
8-
'SL_CHROME60': {
9-
base: 'SauceLabs',
10-
browserName: 'Chrome',
11-
platform: 'Windows 10',
12-
version: '60.0'
13-
}
8+
'SL_CHROME60':
9+
{base: 'SauceLabs', browserName: 'Chrome', platform: 'Windows 10', version: '60.0'},
10+
'SL_SAFARI11':
11+
{base: 'SauceLabs', browserName: 'safari', platform: 'macOS 10.13', version: '11.0'},
1412
};
1513

1614
config.set({
@@ -22,11 +20,11 @@ module.exports = function (config) {
2220
startConnect: false,
2321
recordVideo: false,
2422
recordScreenshots: false,
25-
options: {
26-
'selenium-version': '3.5.0',
27-
'command-timeout': 600,
28-
'idle-timeout': 600,
29-
'max-duration': 5400
23+
options: {
24+
'selenium-version': '3.5.0',
25+
'command-timeout': 600,
26+
'idle-timeout': 600,
27+
'max-duration': 5400
3028
}
3129
},
3230

@@ -38,13 +36,12 @@ module.exports = function (config) {
3836

3937
singleRun: true,
4038

41-
plugins: [
42-
'karma-*'
43-
]
39+
plugins: ['karma-*']
4440
});
4541

4642
if (process.env.TRAVIS) {
47-
config.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';
43+
config.sauceLabs.build =
44+
'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';
4845
config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
4946

5047
process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join('');

sauce.conf.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ module.exports = function(config, ignoredLaunchers) {
66

77
var basicLaunchers = {
88
'SL_CHROME': {base: 'SauceLabs', browserName: 'chrome', version: '48'},
9-
'SL_CHROME_60': {base: 'SauceLabs', browserName: 'chrome', version: '60'},
9+
'SL_CHROME_65': {base: 'SauceLabs', browserName: 'chrome', version: '60'},
1010
'SL_FIREFOX': {base: 'SauceLabs', browserName: 'firefox', version: '52'},
11-
'SL_FIREFOX_54': {base: 'SauceLabs', browserName: 'firefox', version: '54'},
11+
'SL_FIREFOX_59': {base: 'SauceLabs', browserName: 'firefox', version: '54'},
1212
/*'SL_SAFARI7': {
1313
base: 'SauceLabs',
1414
browserName: 'safari',

test/browser-zone-setup.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if (typeof window !== 'undefined') {
1212
import '../lib/common/to-string';
1313
import '../lib/browser/browser';
1414
import '../lib/browser/webapis-user-media';
15+
import '../lib/browser/webapis-media-query';
1516
import '../lib/testing/zone-testing';
1617
import '../lib/zone-spec/task-tracking';
1718
import '../lib/zone-spec/wtf';
@@ -20,3 +21,4 @@ import '../lib/testing/promise-testing';
2021
import '../lib/testing/async-testing';
2122
import '../lib/testing/fake-async';
2223
import '../lib/browser/webapis-resize-observer';
24+
import '../lib/rxjs/rxjs-fake-async';

test/browser/MediaQuery.spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import '../../lib/browser/webapis-media-query';
10-
119
import {zoneSymbol} from '../../lib/common/utils';
1210
import {ifEnvSupports} from '../test-util';
1311
declare const global: any;

test/browser/Notification.spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import '../../lib/browser/webapis-notification';
10-
119
import {zoneSymbol} from '../../lib/common/utils';
1210
import {ifEnvSupports} from '../test-util';
1311
declare const window: any;

test/main.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ if ((window as any)[(Zone as any).__symbol__('setTimeout')]) {
2828
} else {
2929
// this means that Zone has not patched the browser yet, which means we must be running in
3030
// build mode and need to load the browser patch.
31-
browserPatchedPromise = System.import('/base/build/test/browser-zone-setup');
31+
browserPatchedPromise = System.import('/base/build/test/browser-zone-setup').then(() => {
32+
let testFrameworkPatch = typeof(window as any).Mocha !== 'undefined' ?
33+
'/base/build/lib/mocha/mocha' :
34+
'/base/build/lib/jasmine/jasmine';
35+
return System.import(testFrameworkPatch);
36+
});
3237
}
3338

3439
browserPatchedPromise.then(() => {

test/node_entry_point.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ import '../lib/testing/zone-testing';
1919
import '../lib/zone-spec/task-tracking';
2020
import '../lib/zone-spec/wtf';
2121
import '../lib/rxjs/rxjs';
22-
23-
import '../lib/testing/promise-testing';
24-
import '../lib/testing/async-testing';
25-
import '../lib/testing/fake-async';
22+
import '../lib/rxjs/rxjs-fake-async';
2623
// Setup test environment
24+
import '../lib/jasmine/jasmine';
2725
import './test-env-setup-jasmine';
2826

2927
// List all tests here:

test/test-env-setup-jasmine.ts

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
*/
88

99
(<any>jasmine).DEFAULT_TIMEOUT_INTERVAL = 5000;
10-
import '../lib/jasmine/jasmine';

test/test-env-setup-mocha.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import '../lib/mocha/mocha';
1010
declare const global: any;
1111

1212
((context: any) => {
13-
context['jasmine'] = global['jasmine'] || {};
13+
context['jasmine'] = context['jasmine'] || {};
1414
context['jasmine'].createSpy = function(spyName: string) {
1515
let spy: any = function(...params: any[]) {
1616
spy.countCall++;
@@ -183,4 +183,4 @@ declare const global: any;
183183
}
184184
};
185185
};
186-
})(window);
186+
})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);

0 commit comments

Comments
 (0)