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

fix(test): karma-dist should test bundle under dist #1049

Merged
merged 1 commit into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 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.Scheduler',
'rxjs/scheduler/asap': 'Rx.Scheduler',
'rxjs/scheduler/async': 'Rx.Scheduler',
'rxjs/symbol/rxSubscriber': 'Rx.Symbol'
}
},
Expand Down Expand Up @@ -404,9 +406,9 @@ function nodeTest(specFiles, cb) {
require('./build/lib/node/rollup-main');
var args = process.argv;
if (args.length > 3) {
require('./build/test/test-env-setup-jasmine' + args[3]);
require('./build/test/test-env-setup-jasmine' + args[3]);
}
var JasmineRunner = require('jasmine');
var JasmineRunner = require('jasmine');
var JasmineRunner = require('jasmine');
var jrunner = new JasmineRunner();

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
17 changes: 15 additions & 2 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.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/webapis-notification.js');
config.files.push('dist/zone-patch-user-media.js');
config.files.push('dist/zone-patch-resize-observer.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/async-test.js');
config.files.push('dist/fake-async-test.js');
config.files.push('dist/task-tracking.js');
config.files.push('dist/zone-patch-promise-test.js');
config.files.push('dist/wtf.js');
config.files.push('dist/zone-testing.js');
config.files.push('build/test/main.js');
};
29 changes: 13 additions & 16 deletions sauce-selenium3.conf.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Sauce configuration with Welenium drivers 3+

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

var customLaunchers = {
'SL_CHROME60': {
base: 'SauceLabs',
browserName: 'Chrome',
platform: 'Windows 10',
version: '60.0'
}
'SL_CHROME60':
{base: 'SauceLabs', browserName: 'Chrome', platform: 'Windows 10', version: '60.0'},
'SL_SAFARI11':
{base: 'SauceLabs', browserName: 'safari', platform: 'macOS 10.13', version: '11.0'},
};

config.set({
Expand All @@ -22,11 +20,11 @@ module.exports = function (config) {
startConnect: false,
recordVideo: false,
recordScreenshots: false,
options: {
'selenium-version': '3.5.0',
'command-timeout': 600,
'idle-timeout': 600,
'max-duration': 5400
options: {
'selenium-version': '3.5.0',
'command-timeout': 600,
'idle-timeout': 600,
'max-duration': 5400
}
},

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

singleRun: true,

plugins: [
'karma-*'
]
plugins: ['karma-*']
});

if (process.env.TRAVIS) {
config.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';
config.sauceLabs.build =
'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';
config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;

process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join('');
Expand Down
4 changes: 2 additions & 2 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: '60'},
'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: '54'},
/*'SL_SAFARI7': {
base: 'SauceLabs',
browserName: 'safari',
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 @@ -12,6 +12,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/testing/zone-testing';
import '../lib/zone-spec/task-tracking';
import '../lib/zone-spec/wtf';
Expand All @@ -20,3 +21,4 @@ import '../lib/testing/promise-testing';
import '../lib/testing/async-testing';
import '../lib/testing/fake-async';
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
7 changes: 6 additions & 1 deletion test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ 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(() => {
Expand Down
6 changes: 2 additions & 4 deletions test/node_entry_point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ import '../lib/testing/zone-testing';
import '../lib/zone-spec/task-tracking';
import '../lib/zone-spec/wtf';
import '../lib/rxjs/rxjs';

import '../lib/testing/promise-testing';
import '../lib/testing/async-testing';
import '../lib/testing/fake-async';
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';
4 changes: 2 additions & 2 deletions test/test-env-setup-mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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 @@ -183,4 +183,4 @@ declare const global: any;
}
};
};
})(window);
})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
Loading