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

Commit 0720d79

Browse files
JiaLiPassionmhevery
authored andcommitted
fix(test): karma-dist should test bundle under dist (#1049)
1 parent f238908 commit 0720d79

14 files changed

Lines changed: 158 additions & 185 deletions

‎gulpfile.js‎

Lines changed: 4 additions & 2 deletions
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
varargs=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-
varJasmineRunner=require('jasmine');
411+
varJasmineRunner=require('jasmine');
410412
varJasmineRunner=require('jasmine');
411413
varjrunner=newJasmineRunner();
412414

‎karma-base.conf.js‎

Lines changed: 12 additions & 18 deletions
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‎

Lines changed: 15 additions & 2 deletions
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(leti=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‎

Lines changed: 3 additions & 6 deletions
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‎

Lines changed: 13 additions & 16 deletions
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
varcustomLaunchers={
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‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ module.exports = function(config, ignoredLaunchers) {
66

77
varbasicLaunchers={
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‎

Lines changed: 2 additions & 0 deletions
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‎

Lines changed: 0 additions & 2 deletions
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
declareconstglobal: any;

‎test/browser/Notification.spec.ts‎

Lines changed: 0 additions & 2 deletions
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
declareconstwindow: any;

‎test/main.ts‎

Lines changed: 6 additions & 1 deletion
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+
lettestFrameworkPatch=typeof(windowasany).Mocha!=='undefined' ?
33+
'/base/build/lib/mocha/mocha' :
34+
'/base/build/lib/jasmine/jasmine';
35+
returnSystem.import(testFrameworkPatch);
36+
});
3237
}
3338

3439
browserPatchedPromise.then(()=>{

0 commit comments

Comments
 (0)