diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-27 12:39:10 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-27 12:39:10 +0100 |
commit | 08b27426fa631a6200a5423161770acab50403bd (patch) | |
tree | fce0be045cd8a4e023d05c3733ba08cb68de10cc /.config | |
parent | aaefd015deaea6e49c32311e0dc76286662408fd (diff) | |
parent | 4e5ec5f33011bc8ea1af339fd6d7d6fba6fcd057 (diff) | |
download | svg.js-08b27426fa631a6200a5423161770acab50403bd.tar.gz svg.js-08b27426fa631a6200a5423161770acab50403bd.zip |
Merge branch 'feature/tests2' into 3.0.0
Diffstat (limited to '.config')
-rw-r--r-- | .config/karma.conf.common.js (renamed from .config/karma.quick.js) | 62 | ||||
-rw-r--r-- | .config/karma.conf.js | 149 | ||||
-rw-r--r-- | .config/karma.conf.saucelabs.js | 148 | ||||
-rw-r--r-- | .config/polyfillList.js | 11 | ||||
-rw-r--r-- | .config/rollup.config.js | 111 | ||||
-rw-r--r-- | .config/rollup.polyfills.js | 20 |
6 files changed, 368 insertions, 133 deletions
diff --git a/.config/karma.quick.js b/.config/karma.conf.common.js index 8d6dc2e..56c249f 100644 --- a/.config/karma.quick.js +++ b/.config/karma.conf.common.js @@ -1,28 +1,33 @@ -// Karma configuration -// Generated on Tue Oct 04 2016 13:53:46 GMT+0200 (CEST) +// Karma shared configuration -module.exports = function(config) { - config.set({ +const os = require('os') +const cpuCount = os.cpus().length +module.exports = function (config) { + return { // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '../', - // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['jasmine'], - // list of files / patterns to load in the browser files: [ '.config/pretest.js', + 'spec/RAFPlugin.js', + { + pattern: 'spec/fixtures/fixture.css', + included: false, + served: true + }, { - pattern: 'spec/fixture.css', + pattern: 'spec/fixtures/fixture.svg', included: false, served: true }, { - pattern: 'spec/fixture.svg', + pattern: 'spec/fixtures/pixel.png', included: false, served: true }, @@ -30,53 +35,32 @@ module.exports = function(config) { 'spec/spec/*.js' ], - - // list of files to exclude - exclude: [], - - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: {}, - - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress'], - - - // configure the coverage reporter - coverageReporter: {}, - + proxies: { + '/fixtures/': '/base/spec/fixtures/' + }, // web server port - port: 9875, - + port: 9876, // enable / disable colors in the output (reporters and logs) colors: true, - // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_ERROR, - + logLevel: config.LOG_INFO, // enable / disable watching file and executing tests whenever any file changes autoWatch: false, - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], - // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: true, // Concurrency level // how many browser should be started simultaneous - concurrency: 1 - }) + concurrency: cpuCount || Infinity, + + // list of files to exclude + exclude: [], + } } diff --git a/.config/karma.conf.js b/.config/karma.conf.js index 61fe206..57cf14f 100644 --- a/.config/karma.conf.js +++ b/.config/karma.conf.js @@ -1,101 +1,62 @@ // Karma configuration -// Generated on Tue Oct 04 2016 13:53:46 GMT+0200 (CEST) - -module.exports = function(config) { - config.set({ - - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '../', - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['jasmine'], +const karmaCommon = require('./karma.conf.common.js') + +let chromeBin = 'ChromeHeadless' +if (process.platform === 'linux') { + // We need to choose either Chrome or Chromium. + // Canary is not available on linux. + // If we do not find Chromium then we can deduce that + // either Chrome is installed or there is no Chrome variant at all, + // in which case karma-chrome-launcher will output an error. + // If `which` finds nothing it will throw an error. + const { execSync } = require('child_process') + + try { + if (execSync('which chromium-browser')) chromeBin = 'ChromiumHeadless' + } catch (e) {} +} - // list of files / patterns to load in the browser - files: [ - '.config/pretest.js', - 'spec/RAFPlugin.js', - { - pattern: 'spec/fixtures/fixture.css', - included: false, - served: true +module.exports = function (config) { + config.set( + Object.assign(karmaCommon(config), { + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + 'dist/svg.js': ['coverage'] }, - { - pattern: 'spec/fixtures/fixture.svg', - included: false, - served: true - }, - { - pattern: 'spec/fixtures/pixel.png', - included: false, - served: true - }, - 'dist/svg.js', - 'spec/spec/*.js' - ], - - proxies: { - '/fixtures/': '/base/spec/fixtures/' - }, - - - // list of files to exclude - exclude: [], - - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - 'dist/svg.js': ['coverage'] - }, - - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress', 'coverage'], + // this specifies which plugins karma should load + // by default all karma plugins, starting with `karma-` will load + // so if you are really puzzled why something isn't working, then comment + // out plugins: [] - it's here to make karma load faster + // get possible karma plugins by `ls node_modules | grep 'karma-*'` + plugins: [ + 'karma-chrome-launcher', + 'karma-coverage', + 'karma-firefox-launcher', + 'karma-jasmine', + ], + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress', 'coverage'], + + // configure the coverage reporter + coverageReporter: { + // Specify a reporter type. + type: 'lcov', + dir: 'coverage/', + subdir: function(browser) { + // normalization process to keep a consistent browser name accross different OS + return browser.toLowerCase().split(/[ /-]/)[0]; // output the results into: './coverage/firefox/' + } + }, - // configure the coverage reporter - coverageReporter: { - // Specify a reporter type. - type: 'lcov', - dir: 'coverage/', - subdir: function(browser) { - // normalization process to keep a consistent browser name accross different OS - return browser.toLowerCase().split(/[ /-]/)[0]; // output the results into: './coverage/firefox/' - } - }, - - - // web server port - port: 9876, - - - // enable / disable colors in the output (reporters and logs) - colors: true, - - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, - - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['ChromeHeadless', 'FirefoxHeadless'], - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: false, - - // Concurrency level - // how many browser should be started simultaneous - concurrency: Infinity - }) + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: [chromeBin, 'FirefoxHeadless'], + }) + ) } diff --git a/.config/karma.conf.saucelabs.js b/.config/karma.conf.saucelabs.js new file mode 100644 index 0000000..922d749 --- /dev/null +++ b/.config/karma.conf.saucelabs.js @@ -0,0 +1,148 @@ +// Karma configuration +// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator + +// TODO: remove dotenv after local test +require('dotenv').config() + +const karmaCommon = require('./karma.conf.common.js') + +const SauceLabsLaunchers = { + /** Real mobile devices are not available + * Your account does not have access to Android devices. + * Please contact sales@saucelabs.com to add this feature to your account.*/ + /*sl_android_chrome: { + base: 'SauceLabs', + appiumVersion: '1.5.3', + deviceName: 'Samsung Galaxy S7 Device', + deviceOrientation: 'portrait', + browserName: 'Chrome', + platformVersion: '6.0', + platformName: 'Android' + },*/ + /* sl_android: { + base: 'SauceLabs', + browserName: 'Android', + deviceName: 'Android Emulator', + deviceOrientation: 'portrait' + },*/ + SL_firefox_latest: { + base: 'SauceLabs', + browserName: 'firefox', + version: 'latest' + }, + SL_chrome_latest: { + base: 'SauceLabs', + browserName: 'chrome', + version: 'latest' + }, + SL_InternetExplorer: { + base: 'SauceLabs', + browserName: 'internet explorer', + version: '11.0' + },/* + sl_windows_edge: { + base: 'SauceLabs', + browserName: 'MicrosoftEdge', + version: 'latest', + platform: 'Windows 10' + }, + sl_macos_safari: { + base: 'SauceLabs', + browserName: 'safari', + platform: 'macOS 10.13', + version: '12.0', + recordVideo: true, + recordScreenshots: true, + screenResolution: '1024x768' + } *//*, + sl_macos_iphone: { + base: 'SauceLabs', + browserName: 'Safari', + deviceName: 'iPhone SE Simulator', + deviceOrientation: 'portrait', + platformVersion: '10.2', + platformName: 'iOS' + } + 'SL_Chrome': { + base: 'SauceLabs', + browserName: 'chrome', + version: '48.0', + platform: 'Linux' + }, + 'SL_Firefox': { + base: 'SauceLabs', + browserName: 'firefox', + version: '50.0', + platform: 'Windows 10' + }, + 'SL_Safari': { + base: 'SauceLabs', + browserName: 'safari', + platform: 'OS X 10.11', + version: '10.0' + } */ +} + + +module.exports = function(config) { + + if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) { + console.error("SAUCE_USERNAME and SAUCE_ACCESS_KEY must be provided as environment variables.") + console.warn("Aborting Sauce Labs test") + process.exit(1) + } + const settings = Object.assign(karmaCommon(config), { + // Concurrency level + // how many browser should be started simultaneous + // Saucelabs allow up to 5 concurrent sessions on the free open source tier. + concurrency: 5, + + // this specifies which plugins karma should load + // by default all karma plugins, starting with `karma-` will load + // so if you are really puzzled why something isn't working, then comment + // out plugins: [] - it's here to make karma load faster + // get possible karma plugins by `ls node_modules | grep 'karma-*'` + plugins: [ + 'karma-jasmine', + 'karma-sauce-launcher', + ], + + // logLevel: config.LOG_DEBUG, + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['dots', 'saucelabs'], + + customLaunchers: SauceLabsLaunchers, + + // start these browsers + browsers: Object.keys(SauceLabsLaunchers), + sauceLabs: { + testName: 'SVG.js Unit Tests', + // connectOptions: { + // noSslBumpDomains: "all" + // }, + // connectOptions: { + // port: 5757, + // logfile: 'sauce_connect.log' + // }, + }, + + // The number of disconnections tolerated. + // browserDisconnectTolerance: 0, // well, sometimes it helps to just restart + // // How long does Karma wait for a browser to reconnect (in ms). + // browserDisconnectTimeout: 10 * 60 * 1000, + // // How long will Karma wait for a message from a browser before disconnecting from it (in ms). ~ macOS 10.12 needs more than 7 minutes + // browserNoActivityTimeout: 20 * 60 * 1000, + // // Timeout for capturing a browser (in ms). On newer versions of iOS simulator (10.0+), the start up time could be between 3 - 6 minutes. + // captureTimeout: 12 * 60 * 1000, // this is useful if saucelabs takes a long time to boot a vm + + // // Required to make Safari on Sauce Labs play nice. + // // hostname: 'karmalocal.dev' + }) + + console.log(settings) + config.set(settings) + +} diff --git a/.config/polyfillList.js b/.config/polyfillList.js new file mode 100644 index 0000000..34ef4b6 --- /dev/null +++ b/.config/polyfillList.js @@ -0,0 +1,11 @@ +import 'core-js/modules/es6.function.name' +import 'core-js/modules/es6.object.keys' +import 'core-js/modules/es6.symbol' +import 'core-js/modules/es6.set' +import 'core-js/modules/es7.array.includes' +import 'core-js/modules/es6.string.includes' +import 'core-js/modules/es6.array.iterator' +import 'core-js/modules/es7.object.entries' +import 'core-js/modules/es6.object.assign' +import CustomEventPolyfill from '@target/custom-event-polyfill' +CustomEventPolyfill() diff --git a/.config/rollup.config.js b/.config/rollup.config.js new file mode 100644 index 0000000..b7ad5d8 --- /dev/null +++ b/.config/rollup.config.js @@ -0,0 +1,111 @@ +import babel from 'rollup-plugin-babel' +import * as pkg from '../package.json' +// import filesize from 'rollup-plugin-filesize' +import { terser } from 'rollup-plugin-terser' + +const buildDate = Date() + +const headerLong = `/*! +* ${pkg.name} - ${pkg.description} +* @version ${pkg.version} +* ${pkg.homepage} +* +* @copyright ${pkg.author} +* @license ${pkg.license} +* +* BUILT: ${buildDate} +*/;` + +const headerShort = `/*! ${pkg.name} v${pkg.version} ${pkg.license}*/;` + +const config = esm => ({ + input: './src/svg.js', + output: { + file: esm ? './dist/svg.js' : './dist/svg.min.js', + name: 'SVG', + sourceMap: !esm, + format: esm ? 'esm' : 'iife', + banner: esm ? headerShort : headerLong, + plugins: + esm + ? [] + : [ + babel({ + include: 'src/**', + runtimeHelpers: true, + babelrc: false, + presets: [["@babel/preset-env", { + modules: false, + targets: { + ie: 9, + chrome: 49, + edge: 14, + firefox: 45, + safari: 10 + }, + useBuiltIns: 'usage' + }]] + }), + terser() + ] + } +}) + +const modes = [true, false] + +// console.log(modes.map(config)) +export default modes.map(config) + +// export default [ +// { +// input: './src/svg.js', +// output: { +// file: 'dist/svg.js', +// name: 'SVG', +// sourceMap: true, +// format: 'iife', +// banner: headerLong +// }, +// plugins: [ +// // resolve({browser: true}), +// // commonjs(), +// babel({ +// include: 'src/**', +// runtimeHelpers: true, +// babelrc: false, +// presets: [["@babel/preset-env", { +// modules: false, +// targets: { +// ie: "9" +// }, +// useBuiltIns: 'usage' +// }]], +// }), +// filesize() +// ] +// },{ +// input: './.config/polyfills.js', +// output: { +// file: 'dist/polyfills.js', +// name: 'SVG', +// sourceMap: true, +// format: 'umd', +// banner: headerLong +// }, +// treeshake: false, +// plugins: [ +// // babel({ +// // runtimeHelpers: true, +// // babelrc: false, +// // presets: [["@babel/preset-env", { +// // modules: false, +// // targets: { +// // ie: "11" +// // }, +// // useBuiltIns: 'usage' +// // }]], +// // }), +// filesize() +// ] +// }, +// ] diff --git a/.config/rollup.polyfills.js b/.config/rollup.polyfills.js new file mode 100644 index 0000000..810db91 --- /dev/null +++ b/.config/rollup.polyfills.js @@ -0,0 +1,20 @@ +import { uglify } from "rollup-plugin-uglify" +import resolve from 'rollup-plugin-node-resolve' +import commonjs from 'rollup-plugin-commonjs' + +export default [ + { + input: './.config/polyfillList.js', + output: { + file: 'dist/polyfills.js', + name: 'polyfills', + sourceMap: 'external', + format: 'iife' + }, + plugins: [ + resolve({browser: true}), + commonjs(), + uglify() + ] + } +] |