mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
138 lines
5.0 KiB
JavaScript
138 lines
5.0 KiB
JavaScript
const path = require('path');
|
|
const {customLaunchers, platformMap} = require('./browser-providers');
|
|
|
|
module.exports = (config) => {
|
|
|
|
config.set({
|
|
basePath: path.join(__dirname, '..'),
|
|
frameworks: ['jasmine'],
|
|
plugins: [
|
|
require('karma-jasmine'),
|
|
require('karma-browserstack-launcher'),
|
|
require('karma-sauce-launcher'),
|
|
require('karma-chrome-launcher'),
|
|
require('karma-firefox-launcher'),
|
|
require('karma-sourcemap-loader'),
|
|
require('karma-coverage'),
|
|
],
|
|
files: [
|
|
{pattern: 'node_modules/core-js/client/core.min.js', included: true, watched: false},
|
|
{pattern: 'node_modules/tslib/tslib.js', included: true, watched: false},
|
|
{pattern: 'node_modules/systemjs/dist/system.js', included: true, watched: false},
|
|
{pattern: 'node_modules/zone.js/dist/zone.min.js', included: true, watched: false},
|
|
{pattern: 'node_modules/zone.js/dist/proxy.min.js', included: true, watched: false},
|
|
{pattern: 'node_modules/zone.js/dist/sync-test.js', included: true, watched: false},
|
|
{pattern: 'node_modules/zone.js/dist/jasmine-patch.min.js', included: true, watched: false},
|
|
{pattern: 'node_modules/zone.js/dist/async-test.js', included: true, watched: false},
|
|
{pattern: 'node_modules/zone.js/dist/fake-async-test.js', included: true, watched: false},
|
|
{pattern: 'node_modules/hammerjs/hammer.min.js', included: true, watched: false},
|
|
{pattern: 'node_modules/moment/min/moment-with-locales.min.js', included: true, watched: false},
|
|
|
|
// Include all Angular dependencies
|
|
{pattern: 'node_modules/@angular/**/*', included: false, watched: false},
|
|
{pattern: 'node_modules/rxjs/**/*', included: false, watched: false},
|
|
|
|
{pattern: 'test/karma-system-config.js', included: true, watched: false},
|
|
{pattern: 'test/karma-test-shim.js', included: true, watched: false},
|
|
|
|
// Include a Material theme in the test suite.
|
|
{pattern: 'dist/packages/**/core/theming/prebuilt/indigo-pink.css', included: true, watched: true},
|
|
|
|
// Includes all package tests and source files into karma. Those files will be watched.
|
|
// This pattern also matches all sourcemap files and TypeScript files for debugging.
|
|
{pattern: 'dist/packages/**/*', included: false, watched: true},
|
|
],
|
|
|
|
customLaunchers: customLaunchers,
|
|
|
|
preprocessors: {
|
|
'dist/packages/**/*.js': ['sourcemap']
|
|
},
|
|
|
|
reporters: ['dots'],
|
|
autoWatch: false,
|
|
|
|
coverageReporter: {
|
|
type : 'json-summary',
|
|
dir : 'dist/coverage/',
|
|
subdir: '.'
|
|
},
|
|
|
|
sauceLabs: {
|
|
testName: 'Angular Material Unit Tests',
|
|
startConnect: false,
|
|
recordVideo: false,
|
|
recordScreenshots: false,
|
|
idleTimeout: 600,
|
|
commandTimeout: 600,
|
|
maxDuration: 5400,
|
|
},
|
|
|
|
browserStack: {
|
|
project: 'Angular Material Unit Tests',
|
|
startTunnel: false,
|
|
retryLimit: 3,
|
|
timeout: 1800,
|
|
video: false,
|
|
},
|
|
|
|
browserDisconnectTimeout: 180000,
|
|
browserDisconnectTolerance: 3,
|
|
browserNoActivityTimeout: 300000,
|
|
captureTimeout: 180000,
|
|
|
|
browsers: ['ChromeHeadlessLocal'],
|
|
singleRun: false,
|
|
|
|
// Try Websocket for a faster transmission first. Fallback to polling if necessary.
|
|
transports: ['websocket', 'polling'],
|
|
|
|
browserConsoleLogOptions: {
|
|
terminal: true,
|
|
level: 'log'
|
|
},
|
|
|
|
client: {
|
|
jasmine: {
|
|
// TODO(jelbourn): re-enable random test order once we can de-flake existing issues.
|
|
random: false
|
|
}
|
|
},
|
|
});
|
|
|
|
if (process.env['TRAVIS']) {
|
|
const buildId = `TRAVIS #${process.env.TRAVIS_BUILD_NUMBER} (${process.env.TRAVIS_BUILD_ID})`;
|
|
|
|
if (process.env['TRAVIS_PULL_REQUEST'] === 'false' &&
|
|
process.env['MODE'] === "travis_required") {
|
|
|
|
config.preprocessors['dist/packages/**/!(*+(.|-)spec).js'] = ['coverage'];
|
|
config.reporters.push('coverage');
|
|
}
|
|
|
|
// The MODE variable is the indicator of what row in the test matrix we're running.
|
|
// It will look like <platform>_<target>, where platform is one of 'saucelabs', 'browserstack'
|
|
// or 'travis'. The target is a reference to different collections of browsers that can run
|
|
// in the previously specified platform.
|
|
const [platform, target] = process.env.MODE.split('_');
|
|
|
|
if (platform === 'saucelabs') {
|
|
config.sauceLabs.build = buildId;
|
|
config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_ID;
|
|
} else if (platform === 'browserstack') {
|
|
config.browserStack.build = buildId;
|
|
config.browserStack.tunnelIdentifier = process.env.TRAVIS_JOB_ID;
|
|
} else if (platform !== 'travis') {
|
|
throw new Error(`Platform "${platform}" unknown, but Travis specified. Exiting.`);
|
|
}
|
|
|
|
if (platform !== 'travis') {
|
|
// To guarantee a better stability for tests running on external browsers, we disable
|
|
// concurrency. Stability is compared to speed more important.
|
|
config.concurrency = 1;
|
|
}
|
|
|
|
config.browsers = platformMap[platform][target.toLowerCase()];
|
|
}
|
|
};
|