Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

refactor(checkbox): Add Jasmine test for checkbox foundation. #5299

Merged
merged 18 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from 8 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
170 changes: 105 additions & 65 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const webpackConfig = require('./webpack.config')[1];

const USING_TRAVISCI = Boolean(process.env.TRAVIS);
const USING_SL = Boolean(process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY);
// If true, runs new suite of Jasmine foundation unit tests.
// Otherwise, runs old Mocha unit tests.
const USE_JASMINE = Boolean(process.env.USE_JASMINE);
joyzhong marked this conversation as resolved.
Show resolved Hide resolved

const HEADLESS_LAUNCHERS = {
/** See https://github.com/travis-ci/travis-ci/issues/8836#issuecomment-348248951 */
Expand Down Expand Up @@ -63,80 +66,117 @@ const istanbulInstrumenterLoader = {
include: path.resolve('./packages'),
};

module.exports = function(config) {
config.set({
basePath: '',
// Refer https://github.com/karma-runner/karma-mocha
frameworks: ['mocha'],
files: [
// Refer https://github.com/babel/karma-babel-preprocessor
'node_modules/@babel/polyfill/dist/polyfill.js',
'test/unit/index.js',
],
preprocessors: {
'test/unit/index.js': ['webpack', 'sourcemap'],
const mochaConfig = {
basePath: '',
// Refer https://github.com/karma-runner/karma-mocha
frameworks: ['mocha'],
files: [
// Refer https://github.com/babel/karma-babel-preprocessor
'node_modules/@babel/polyfill/dist/polyfill.js',
'test/unit/index.js',
],
preprocessors: {
'test/unit/index.js': ['webpack', 'sourcemap'],
},
reporters: ['progress', 'coverage-istanbul'],
port: 9876,
colors: true,
browsers: browsers,
browserDisconnectTimeout: 40000,
browserNoActivityTimeout: 120000,
captureTimeout: 240000,
concurrency: USING_SL ? 4 : Infinity,
customLaunchers: customLaunchers,

coverageIstanbulReporter: {
'dir': 'coverage',
'reports': ['html', 'lcovonly', 'json'],
'report-config': {
lcovonly: {subdir: '.'},
json: {subdir: '.', file: 'coverage.json'},
},
reporters: ['progress', 'coverage-istanbul'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browsers: browsers,
browserDisconnectTimeout: 40000,
browserNoActivityTimeout: 120000,
captureTimeout: 240000,
concurrency: USING_SL ? 4 : Infinity,
customLaunchers: customLaunchers,

coverageIstanbulReporter: {
'dir': 'coverage',
'reports': ['html', 'lcovonly', 'json'],
'report-config': {
lcovonly: {subdir: '.'},
json: {subdir: '.', file: 'coverage.json'},
},
// 'emitWarning' causes the tests to fail if the thresholds are not met
'emitWarning': false,
'thresholds': {
statements: 95,
branches: 95,
lines: 95,
functions: 95,
},
// 'emitWarning' causes the tests to fail if the thresholds are not met
'emitWarning': false,
'thresholds': {
statements: 95,
branches: 95,
lines: 95,
functions: 95,
},
},

client: {
mocha: {
reporter: 'html',
ui: 'qunit',
client: {
mocha: {
reporter: 'html',
ui: 'qunit',

// Number of milliseconds to wait for an individual `test(...)` function to complete.
// The default is 2000.
timeout: 10000,
},
// Number of milliseconds to wait for an individual `test(...)` function to complete.
// The default is 2000.
timeout: 10000,
},
},

// Refer https://github.com/webpack-contrib/karma-webpack
webpack: Object.assign({}, webpackConfig, {
plugins: [], // Exclude UglifyJs plugin from test build.
mode: 'development',
module: Object.assign({}, webpackConfig.module, {
// Cover source files when not debugging tests. Otherwise, omit coverage instrumenting to get
// uncluttered source maps.
rules: webpackConfig.module.rules.concat(config.singleRun ? [Object.assign({
enforce: 'post',
test: /\.ts$/,
}, istanbulInstrumenterLoader), Object.assign({
test: /\.js$/,
}, istanbulInstrumenterLoader)] : []),
}),
}),
webpackMiddleware: {
noInfo: true,
stats: 'minimal',
},
};

webpackMiddleware: {
noInfo: true,
stats: 'minimal',
},
const jasmineConfig = {
basePath: '',
frameworks: ['jasmine', 'karma-typescript'],
files: [
'packages/*/!(node_modules)/**/!(*.d).ts',
'packages/*/!(*.d).ts',
'packages/*/test/!(*.d).ts',
'testing/**/*.ts',
],
preprocessors: {
'packages/*/!(node_modules)/**/!(*.d).ts': 'karma-typescript',
'packages/*/!(*.d).ts': 'karma-typescript',
'packages/*/test/!(*.d).ts': 'karma-typescript',
'testing/**/*.ts': 'karma-typescript',
},
reporters: ['progress', 'karma-typescript'],
port: 9876,
colors: true,
browsers: browsers,
browserDisconnectTimeout: 40000,
browserNoActivityTimeout: 120000,
captureTimeout: 240000,
concurrency: USING_SL ? 4 : Infinity,
customLaunchers: customLaunchers,
karmaTypescriptConfig: {
tsconfig: './tsconfig.json',
},
};

module.exports = function(config) {
config.set(Object.assign(USE_JASMINE ? jasmineConfig : mochaConfig), {
logLevel: config.LOG_INFO,
});

if (!USE_JASMINE) {
// Need to set webpack here rather than in `mochaConfig` to read `config.singleRun`.
config.set({
// Refer https://github.com/webpack-contrib/karma-webpack
webpack: Object.assign({}, webpackConfig, {
plugins: [], // Exclude UglifyJs plugin from test build.
mode: 'development',
module: Object.assign({}, webpackConfig.module, {
// Cover source files when not debugging tests. Otherwise, omit coverage instrumenting to get
// uncluttered source maps.
rules: webpackConfig.module.rules.concat(config.singleRun ? [Object.assign({
enforce: 'post',
test: /\.ts$/,
}, istanbulInstrumenterLoader), Object.assign({
test: /\.js$/,
}, istanbulInstrumenterLoader)] : []),
}),
}),
});
}

if (USING_SL) {
const sauceLabsConfig = {
username: process.env.SAUCE_USERNAME,
Expand Down
Loading