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

Commit

Permalink
fix(test): karma-dist should test bundle under dist
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion committed Mar 30, 2018
1 parent a93aa89 commit 7c6e644
Show file tree
Hide file tree
Showing 14 changed files with 294 additions and 327 deletions.
2 changes: 2 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ function generateScript(inFile, outFile, minify, callback) {
'rxjs/Observable': 'Rx',
'rxjs/Subscriber': 'Rx',
'rxjs/Subscription': 'Rx',
'rxjs/Scheduler': 'Rx',
'rxjs/scheduler/asap': 'Rx.Scheduler',
'rxjs/scheduler/async': 'Rx.Scheduler',
'rxjs/symbol/rxSubscriber': 'Rx.Symbol'
}
},
Expand Down
30 changes: 12 additions & 18 deletions karma-base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,39 @@
* found in the LICENSE file at https://angular.io/license
*/

module.exports = function (config) {
module.exports = function(config) {
config.set({
basePath: '',
files: [
'node_modules/systemjs/dist/system-polyfills.js',
'node_modules/systemjs/dist/system.src.js',
'node_modules/systemjs/dist/system-polyfills.js', 'node_modules/systemjs/dist/system.src.js',
'node_modules/whatwg-fetch/fetch.js',
{pattern: 'node_modules/rxjs/**/**/*.js', included: false, watched: false },
{pattern: 'node_modules/rxjs/**/**/*.js.map', included: false, watched: false },
{pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
{pattern: 'node_modules/es6-promise/**/*.js', included: false, watched: false },
{pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
{pattern: 'node_modules/rxjs/**/**/*.js', included: false, watched: false},
{pattern: 'node_modules/rxjs/**/**/*.js.map', included: false, watched: false},
{pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false},
{pattern: 'node_modules/es6-promise/**/*.js', included: false, watched: false},
{pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false},
{pattern: 'test/assets/**/*.*', watched: true, served: true, included: false},
{pattern: 'build/**/*.js.map', watched: true, served: true, included: false},
{pattern: 'build/**/*.js', watched: true, served: true, included: false}
],

plugins: [
require('karma-chrome-launcher'),
require('karma-firefox-launcher'),
require('karma-chrome-launcher'), require('karma-firefox-launcher'),
require('karma-sourcemap-loader')
],

preprocessors: {
'**/*.js': ['sourcemap']
},
preprocessors: {'**/*.js': ['sourcemap']},

exclude: [
'test/microtasks.spec.ts'
],
exclude: ['test/microtasks.spec.ts'],

reporters: ['progress'],

//port: 9876,
// port: 9876,
colors: true,

logLevel: config.LOG_INFO,

browsers: ['Firefox'],
browsers: ['Chrome'],

captureTimeout: 60000,

Expand Down
19 changes: 16 additions & 3 deletions karma-dist-mocha.conf.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@

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

for (let i = 0; i < config.files.length; i++) {
if (config.files[i] === 'dist/zone-testing.js') {
config.files.splice(i, 1);
break;
}
}
config.files.push('dist/long-stack-trace-zone.js');
config.files.push('dist/proxy.js');
config.files.push('dist/sync-test.js');
config.files.push('dist/async-test.js');
config.files.push('dist/fake-async-test.js');
config.files.push('dist/zone-patch-promise-test.js');
config.files.push('dist/mocha-patch.js');
config.plugins.push(require('karma-mocha'));
config.frameworks.push('mocha');
config.client.mocha = {
timeout: 5000 // copied timeout for Jasmine in WebSocket.spec (otherwise Mochas default timeout at 2 sec is to low for the tests)
timeout: 5000 // copied timeout for Jasmine in WebSocket.spec (otherwise Mochas default timeout
// at 2 sec is to low for the tests)
};
};
9 changes: 3 additions & 6 deletions karma-dist.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ module.exports = function(config) {
config.files.push('build/test/test_fake_polyfill.js');
config.files.push('build/test/custom_error.js');
config.files.push('dist/zone.js');
config.files.push('dist/webapis-media-query.js');
config.files.push('dist/zone-patch-user-media.js');
config.files.push('dist/zone-patch-resize-observer.js');
config.files.push('dist/async-test.js');
config.files.push('dist/fake-async-test.js');
config.files.push('dist/long-stack-trace-zone.js');
config.files.push('dist/proxy.js');
config.files.push('dist/sync-test.js');
config.files.push('dist/webapis-notification.js');
config.files.push('dist/task-tracking.js');
config.files.push('dist/wtf.js');
config.files.push('dist/zone-patch-promise-test.js');
config.files.push('dist/zone-testing.js');
config.files.push('build/test/main.js');
};
12 changes: 4 additions & 8 deletions sauce.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ module.exports = function(config, ignoredLaunchers) {

var basicLaunchers = {
'SL_CHROME': {base: 'SauceLabs', browserName: 'chrome', version: '48'},
'SL_CHROME_60': {base: 'SauceLabs', browserName: 'chrome', version: '60'},
'SL_CHROME_65': {base: 'SauceLabs', browserName: 'chrome', version: '65'},
'SL_FIREFOX': {base: 'SauceLabs', browserName: 'firefox', version: '52'},
'SL_FIREFOX_54': {base: 'SauceLabs', browserName: 'firefox', version: '54'},
'SL_FIREFOX_59': {base: 'SauceLabs', browserName: 'firefox', version: '59'},
/*'SL_SAFARI7': {
base: 'SauceLabs',
browserName: 'safari',
Expand All @@ -29,14 +29,10 @@ module.exports = function(config, ignoredLaunchers) {
platform: 'OS X 10.10',
version: '7.1'
},*/
/*'SL_IOS8': {
base: 'SauceLabs',
browserName: 'iphone',
platform: 'OS X 10.10',
version: '8.4'
},*/
'SL_IOS8': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '8.4.1'},
'SL_IOS9': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '9.3'},
'SL_IOS10': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '10.2'},
'SL_IOS11': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '11.2'},
'SL_IE9': {
base: 'SauceLabs',
browserName: 'internet explorer',
Expand Down
2 changes: 2 additions & 0 deletions test/browser-zone-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if (typeof window !== 'undefined') {
import '../lib/common/to-string';
import '../lib/browser/browser';
import '../lib/browser/webapis-user-media';
import '../lib/browser/webapis-media-query';
import '../lib/zone-spec/async-test';
import '../lib/zone-spec/fake-async-test';
import '../lib/zone-spec/long-stack-trace';
Expand All @@ -21,3 +22,4 @@ import '../lib/zone-spec/wtf';
import '../lib/extra/cordova';
import '../lib/testing/promise-testing';
import '../lib/browser/webapis-resize-observer';
import '../lib/rxjs/rxjs-fake-async';
2 changes: 0 additions & 2 deletions test/browser/MediaQuery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/

import '../../lib/browser/webapis-media-query';

import {zoneSymbol} from '../../lib/common/utils';
import {ifEnvSupports} from '../test-util';
declare const global: any;
Expand Down
2 changes: 0 additions & 2 deletions test/browser/Notification.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/

import '../../lib/browser/webapis-notification';

import {zoneSymbol} from '../../lib/common/utils';
import {ifEnvSupports} from '../test-util';
declare const window: any;
Expand Down
8 changes: 6 additions & 2 deletions test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ if ((window as any)[(Zone as any).__symbol__('setTimeout')]) {
} else {
// this means that Zone has not patched the browser yet, which means we must be running in
// build mode and need to load the browser patch.
browserPatchedPromise = System.import('/base/build/test/browser-zone-setup');
browserPatchedPromise = System.import('/base/build/test/browser-zone-setup').then(() => {
let testFrameworkPatch = typeof(window as any).Mocha !== 'undefined' ?
'/base/build/lib/mocha/mocha' :
'/base/build/lib/jasmine/jasmine';
return System.import(testFrameworkPatch);
});
}

browserPatchedPromise.then(() => {
let testFrameworkPatch = typeof(window as any).Mocha !== 'undefined' ?
'/base/build/test/test-env-setup-mocha' :
'/base/build/test/test-env-setup-jasmine';
// Setup test environment
System.import(testFrameworkPatch).then(() => {
System.import('/base/build/test/browser_entry_point')
.then(
Expand Down
2 changes: 2 additions & 0 deletions test/node_entry_point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import '../lib/zone-spec/wtf';
import '../lib/rxjs/rxjs';

import '../lib/testing/promise-testing';
import '../lib/rxjs/rxjs-fake-async';
// Setup test environment
import '../lib/jasmine/jasmine';
import './test-env-setup-jasmine';

// List all tests here:
Expand Down
1 change: 0 additions & 1 deletion test/test-env-setup-jasmine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
*/

(<any>jasmine).DEFAULT_TIMEOUT_INTERVAL = 5000;
import '../lib/jasmine/jasmine';
7 changes: 2 additions & 5 deletions test/test-env-setup-mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/

import '../lib/mocha/mocha';
declare const global: any;

((context: any) => {
context['jasmine'] = global['jasmine'] || {};
context['jasmine'] = context['jasmine'] || {};
context['jasmine'].createSpy = function(spyName: string) {
let spy: any = function(...params: any[]) {
spy.countCall++;
Expand Down Expand Up @@ -169,4 +166,4 @@ declare const global: any;
}
};
};
})(window);
})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
Loading

0 comments on commit 7c6e644

Please sign in to comment.