From ce4f64dc73a7d236d8520b39b28d8b36711ec524 Mon Sep 17 00:00:00 2001 From: daviskoh Date: Wed, 4 Feb 2015 21:45:10 -0500 Subject: [PATCH 1/2] Add Karma Test Runner * update package.json w/ karma dependencies * add npm test script * add node_modules to .gitignore --- .gitignore | 3 ++- karma.conf.js | 42 ++++++++++++++++++++++++++++++++++++++++++ package.json | 10 ++++++++-- 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 karma.conf.js diff --git a/.gitignore b/.gitignore index 98861dbd..a4268a07 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ a.out *.class /**/java/out/* /**/.idea/workspace.xml -/lib/ \ No newline at end of file +/lib/ +/node_modules/ diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..6237f85f --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,42 @@ +'use strict'; + +module.exports = function (config) { + config.set({ + + // base path, that will be used to resolve files and exclude + basePath: 'src', + + // frameworks to use + frameworks: ['jasmine'], + + // list of files / patterns to load in the browser + files: [ + 'Layout.js', + 'Layout-test-utils.js', + '__tests__/Layout-test.js', + '__tests__/Layout-consts-test.js' + ], + + plugins: [ + 'karma-chrome-launcher', + 'karma-jasmine' + ], + + // 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, + + browsers: ['Chrome'], + + // If browser does not capture in given timeout [ms], kill it + captureTimeout: 60000, + + singleRun: false + }); +}; \ No newline at end of file diff --git a/package.json b/package.json index d513a633..541ee749 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Reimplementation of CSS layout using pure JavaScript", "main": "src/Layout.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "./node_modules/karma/bin/karma start ./karma.conf.js --single-run" }, "repository": { "type": "git", @@ -15,5 +15,11 @@ "bugs": { "url": "https://github.com/facebook/css-layout/issues" }, - "homepage": "https://github.com/facebook/css-layout" + "homepage": "https://github.com/facebook/css-layout", + "devDependencies": { + "jasmine-core": "^2.2.0", + "karma": "^0.12.31", + "karma-chrome-launcher": "^0.1.7", + "karma-jasmine": "^0.3.5" + } } From 58198d8102441cd4975ba8b6095d282184d6e956 Mon Sep 17 00:00:00 2001 From: daviskoh Date: Wed, 4 Feb 2015 21:56:40 -0500 Subject: [PATCH 2/2] adhere to coding style --- karma.conf.js | 56 +++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 6237f85f..9968bef7 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,42 +1,42 @@ 'use strict'; module.exports = function (config) { - config.set({ + config.set({ - // base path, that will be used to resolve files and exclude - basePath: 'src', + // base path, that will be used to resolve files and exclude + basePath: 'src', - // frameworks to use - frameworks: ['jasmine'], + // frameworks to use + frameworks: ['jasmine'], - // list of files / patterns to load in the browser - files: [ - 'Layout.js', - 'Layout-test-utils.js', - '__tests__/Layout-test.js', - '__tests__/Layout-consts-test.js' - ], + // list of files / patterns to load in the browser + files: [ + 'Layout.js', + 'Layout-test-utils.js', + '__tests__/Layout-test.js', + '__tests__/Layout-consts-test.js' + ], - plugins: [ - 'karma-chrome-launcher', - 'karma-jasmine' - ], + plugins: [ + 'karma-chrome-launcher', + 'karma-jasmine' + ], - // web server port - port: 9876, + // web server port + port: 9876, - // enable / disable colors in the output (reporters and logs) - colors: true, + // 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, + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, - browsers: ['Chrome'], + browsers: ['Chrome'], - // If browser does not capture in given timeout [ms], kill it - captureTimeout: 60000, + // If browser does not capture in given timeout [ms], kill it + captureTimeout: 60000, - singleRun: false - }); + singleRun: false + }); }; \ No newline at end of file