Skip to content

Commit

Permalink
Merge pull request #1557 from yabwe/karma
Browse files Browse the repository at this point in the history
Karma Init
  • Loading branch information
ksorv authored Aug 2, 2020
2 parents 26d80dd + a7161c0 commit 2c0af6b
Show file tree
Hide file tree
Showing 7 changed files with 300 additions and 167 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
.DS_Store
*.swo
node_modules/
.env
.sass-cache/
npm-debug.log
.grunt/
_SpecRunner.html
reports/
coverage/
._*
local.log
browserstack.err

# IDE
.idea/
package-lock.json


10 changes: 1 addition & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,4 @@ before_script:
- npm install -g grunt-cli

script:
- npm run test:ci

addons:
sauce_connect: true

env:
global:
- secure: uSn+psGGU4v96aLw3egOywFLaZ1nAjwzbwpn/yUWXanPllHi7LZIe4tY41GfrE4CmD+brAQFRPkuxUnk5uOdtnwLPo5eSg/NAWEIVws2/UnPisr63YopB/LTLP9NqcUklZ8IsE3gcXrhMZWJBm5wfXj9pO+182zp6XHzID1yDAE=
- secure: On1IPA/AVPSJitzCK8XfYuYRJDi2/jNEP2Wux8S2L/AvmAQ0tUQN7ivxgoyZUb9Bez6OkxfFSDBsrIR3p7MiSIIZSPOD55/QiJyUtmH25WuIcrjyytaCEvNv2OeCNwS2EGQe0ToxdwRCCqBPJRLJTMyuvlnSkAKmKPPfdXjcCOM=
- npm run test:ci
128 changes: 11 additions & 117 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,52 +35,7 @@ module.exports = function (grunt) {
'src/js/core.js',
'src/js/defaults/options.js',
'src/js/version.js'
],
browsers = [{
browserName: 'internet explorer',
version: '9',
platform: 'WIN7'
}, {
browserName: 'internet explorer',
version: '10',
platform: 'WIN8'
}, {
browserName: 'internet explorer',
version: '11',
platform: 'WIN8.1'
}, {
browserName: 'internet explorer',
version: '11',
platform: 'Windows 10'
}, {
browserName: 'MicrosoftEdge',
platform: 'Windows 10'
}, {
browserName: 'chrome',
platform: 'WIN8.1'
}, {
browserName: 'chrome',
platform: 'Windows 10'
}, {
browserName: 'googlechrome',
platform: 'OS X 10.11'
}, {
browserName: 'firefox',
platform: 'WIN8.1'
}, {
browserName: 'firefox',
platform: 'Windows 10'
}, {
browserName: 'firefox',
platform: 'OS X 10.11'
}, {
browserName: 'safari',
platform: 'OS X 10.10'
}, {
browserName: 'safari',
platform: 'OS X 10.11'
}];

];
gruntConfig.connect = {
server: {
options: {
Expand Down Expand Up @@ -119,46 +74,12 @@ module.exports = function (grunt) {
}
};

gruntConfig.jasmine = {
suite: {
src: [srcFiles],
options: {
specs: ['spec/*.spec.js'],
helpers: 'spec/helpers/*.js',
vendor: [
'node_modules/lodash/index.js',
'spec/vendor/jasmine-jsreporter.js',
'spec/vendor/jasmine-jsreporter-script.js'
],
polyfills: [
'src/js/polyfills.js'
],
styles: 'dist/css/*.css',
junit: {
path: 'reports/jasmine/',
consolidate: true
},
keepRunner: true,
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'reports/jasmine/coverage.json',
report: [{
type: 'lcov',
options: {
dir: 'reports/jasmine/lcov'
}
}],
files: srcFiles.concat('!src/js/extensions/deprecated/*')
},
summary: true
}
gruntConfig.karma = {
unit: {
configFile: 'karma.conf.js'
},
spec: {
src: 'src/js/**/*.js',
options: {
specs: ['spec/<%= globalConfig.file %>.spec.js'],
helpers: 'spec/helpers/*.js'
}
dev: {
configFile: 'karma.dev.conf.js'
}
};

Expand Down Expand Up @@ -287,31 +208,6 @@ module.exports = function (grunt) {
}
};

gruntConfig['saucelabs-jasmine'] = {
all: {
options: {
urls: ['http://localhost:9999/_SpecRunner.html'],
tunnelTimeout: 5,
build: process.env.TRAVIS_JOB_ID,
concurrency: 3,
browsers: browsers,
sauceConfig: {
public: 'public',
build: process.env.TRAVIS_JOB_ID,
name: 'medium-editor-tests',
maxDuration: 900,
idleTimeout: 600
}
}
}
};

gruntConfig.coveralls = {
dist: {
src: 'reports/jasmine/lcov/lcov.info'
}
};

gruntConfig.bump = {
options: {
files: ['package.json', 'src/js/version.js'],
Expand All @@ -333,14 +229,13 @@ module.exports = function (grunt) {
});

if (parseInt(process.env.TRAVIS_PULL_REQUEST, 10) > 0) {
grunt.registerTask('travis', ['jshint', 'jscs', 'jasmine:suite', 'csslint', 'coveralls']);
grunt.registerTask('travis', ['jshint', 'jscs', 'karma:unit', 'csslint']);
} else {
grunt.registerTask('travis', ['connect', 'jshint', 'jscs', 'jasmine:suite', 'csslint', 'saucelabs-jasmine', 'coveralls']);
grunt.registerTask('travis', ['jshint', 'jscs', 'csslint', 'karma:unit']);
}

grunt.registerTask('test', ['jshint', 'jscs', 'concat', 'jasmine:suite', 'csslint']);
grunt.registerTask('sauce', ['connect', 'saucelabs-jasmine']);
grunt.registerTask('js', ['jshint', 'jscs', 'concat', 'jasmine:suite', 'uglify']);
grunt.registerTask('test', ['jshint', 'jscs', 'concat', 'csslint', 'karma:dev']);
grunt.registerTask('js', ['jshint', 'jscs', 'concat', 'karma:dev', 'uglify']);
grunt.registerTask('css', ['sass', 'autoprefixer', 'cssmin', 'csslint']);
grunt.registerTask('default', ['js', 'css']);

Expand All @@ -349,8 +244,7 @@ module.exports = function (grunt) {
grunt.task.run(taskName + ':spec');
});

// release tasks
grunt.registerTask('patch', ['bump', 'css', 'js']);
grunt.registerTask('minor', ['bump:minor', 'css', 'js']);
grunt.registerTask('major', ['bump:major', 'css', 'js']);
};
};
150 changes: 150 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/* global module */

module.exports = function (config) {
config.set({

browserStack: {
apiClientEndpoint: 'https://api.browserstack.com',
timeout: 600
},

customLaunchers: {
WIN81Chrome: {
'base': 'BrowserStack',
'os': 'Windows',
'os_version': '8.1',
'browser': 'chrome'
},
WIN81Firefox: {
'base': 'BrowserStack',
'os': 'Windows',
'os_version': '8.1',
'browser': 'firefox'
},
WIN81Edge: {
'base': 'BrowserStack',
'os': 'Windows',
'os_version': '8.1',
'browser': 'edge'
},
WIN10Chrome: {
'base': 'BrowserStack',
'os': 'Windows',
'os_version': '10',
'browser': 'chrome'
},
WIN10Firefox: {
'base': 'BrowserStack',
'os': 'Windows',
'os_version': '10',
'browser': 'firefox'
},
WIN10Edge: {
'base': 'BrowserStack',
'os': 'Windows',
'os_version': '10',
'browser': 'edge'
},
OSXYosemiteSafari: {
'base': 'BrowserStack',
'os': 'OS X',
'os_version': 'Yosemite',
'browser': 'safari'
},
OSXElCapitanChrome: {
'base': 'BrowserStack',
'os': 'OS X',
'os_version': 'El Capitan',
'browser': 'chrome'
},
OSXElCapitanSafari: {
'base': 'BrowserStack',
'os': 'OS X',
'os_version': 'El Capitan',
'browser': 'safari'
},
OSXElCapitanFirefox: {
'base': 'BrowserStack',
'os': 'OS X',
'os_version': 'El Capitan',
'browser': 'firefox'
}
},

basePath: '',
frameworks: ['jasmine'],

files: [
'dist/css/*.css',
'node_modules/lodash/index.js',
'src/js/polyfills.js',
'src/js/globals.js',
'src/js/util.js',
'src/js/extension.js',
'src/js/selection.js',
'src/js/events.js',
'src/js/extensions/button.js',
'src/js/defaults/buttons.js',
'src/js/extensions/form.js',
'src/js/extensions/anchor.js',
'src/js/extensions/anchor-preview.js',
'src/js/extensions/auto-link.js',
'src/js/extensions/file-dragging.js',
'src/js/extensions/keyboard-commands.js',
'src/js/extensions/fontname.js',
'src/js/extensions/fontsize.js',
'src/js/extensions/paste.js',
'src/js/extensions/placeholder.js',
'src/js/extensions/toolbar.js',
'src/js/extensions/deprecated/image-dragging.js',
'src/js/core.js',
'src/js/defaults/options.js',
'src/js/version.js',
'spec/helpers/util.js',
'spec/*.spec.js'
],

exclude: [
'src/js/extensions/deprecated/*'
],

preprocessors: {
},

plugins: [
'karma-jasmine',
'karma-spec-reporter',
'karma-jasmine-html-reporter',
'karma-browserstack-launcher',
'karma-phantomjs-launcher',
'karma-firefox-launcher',
'karma-chrome-launcher',
'karma-coverage',
'karma-coveralls'
],

reporters: ['coverage', 'coveralls', 'BrowserStack', 'dots', 'spec', 'kjhtml'],

coverageReporter: {
type: 'lcov',
dir: 'coverage/'
},

port: 9876,

logLevel: config.LOG_ERROR,
colors: true,

autoWatch: false,

browsers: ['WIN10Edge', 'WIN10Chrome', 'WIN10Firefox', 'OSXElCapitanChrome', 'OSXElCapitanFirefox', 'OSXYosemiteSafari'],

client: {
clearContext: false
},

singleRun: true,

concurrency: Infinity
});
};
Loading

0 comments on commit 2c0af6b

Please sign in to comment.