From 7d5d2e46d22f109df0d0adf4b47b8586f12cfb24 Mon Sep 17 00:00:00 2001 From: Leszek Manicki Date: Fri, 1 Sep 2017 15:23:42 +0200 Subject: [PATCH] Run tests on CI server (and locally with npm test) --- .eslintrc.json | 1 + .gitignore | 2 ++ .travis.yml | 2 +- karma.conf.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 35 +++++++++++++++++++++++++++++++++-- src/__namespace.js | 1 + 6 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 karma.conf.js diff --git a/.eslintrc.json b/.eslintrc.json index 24af0bf..ca3a390 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,6 +6,7 @@ }, "globals": { "dataValues": false, + "module": false, "util": false, "wikibase": false }, diff --git a/.gitignore b/.gitignore index d5434bc..7eb6971 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ composer.lock vendor/ node_modules/ + +.idea/ diff --git a/.travis.yml b/.travis.yml index e8ff643..db586a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_script: script: - composer test - - npm install && npm run eslint + - npm install && npm test notifications: irc: diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..10f1cca --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,44 @@ +module.exports = function ( config ) { + config.set( { + frameworks: [ 'qunit' ], + + files: [ + 'node_modules/jquery/dist/jquery.js', + + // TODO: install JS dependencies using npm + 'vendor/data-values/javascript/lib/util/util.inherit.js', + 'vendor/data-values/javascript/src/dataValues.js', + 'vendor/data-values/javascript/src/DataValue.js', + 'vendor/data-values/javascript/src/values/StringValue.js', + 'vendor/data-values/javascript/src/values/UnDeserializableValue.js', + 'vendor/wikibase/data-model-javascript/src/__namespace.js', + 'vendor/wikibase/data-model-javascript/src/GroupableCollection.js', + 'vendor/wikibase/data-model-javascript/src/Group.js', + 'vendor/wikibase/data-model-javascript/src/Snak.js', + 'vendor/wikibase/data-model-javascript/src/Set.js', + 'vendor/wikibase/data-model-javascript/src/List.js', + 'vendor/wikibase/data-model-javascript/src/*.js', + + 'src/__namespace.js', + 'src/Serializers/Serializer.js', + 'src/Serializers/*.js', + 'src/SerializerFactory.js', + 'src/StrategyProvider.js', + 'src/Deserializers/Deserializer.js', + 'src/Deserializers/*.js', + 'src/DeserializerFactory.js', + 'tests/MockEntity.js', + 'tests/MockEntity.tests.js', + 'tests/StrategyProvider.tests.js', + 'tests/SerializerFactory.tests.js', + 'tests/Serializers/*.js', + 'tests/Deserializers/*.js', + 'tests/DeserializerFactory.tests.js' + ], + + port: 9876, + + logLevel: config.LOG_INFO, + browsers: [ 'PhantomJS' ] + } ); +}; diff --git a/package.json b/package.json index fe63246..05b5acc 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,44 @@ { + "name": "wikibase-serialization", + "description": "JavaScript library containing serializers and deserializers for the Wikibase DataModel.", + "version": "2.1.0", + "contributors": [ + { + "name": "H. Snater", + "url": "http://www.snater.com" + }, + { + "name": "Adrian Lang", + "email": "adrian.lang@wikimedia.de" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/wmde/WikibaseSerializationJavaScript" + }, + "license": "GPL-2.0+", "directories": { "lib": "src", "test": "tests" }, + "support": { + "url": "https://phabricator.wikimedia.org/" + }, + "dependencies": { + "jquery": "^3.2.1" + }, "devDependencies": { "eslint": "^3.19.0", - "eslint-config-wikimedia": "0.4.0" + "eslint-config-wikimedia": "0.4.0", + "karma": "^1.7.1", + "karma-cli": "^1.0.1", + "karma-phantomjs-launcher": "^1.0.4", + "karma-qunit": "^1.2.1", + "qunit": "^1.0.0" }, "scripts": { - "eslint": "eslint ." + "test": "npm run eslint && npm run run-tests", + "eslint": "eslint .", + "run-tests": "karma start --single-run" } } diff --git a/src/__namespace.js b/src/__namespace.js index 7874cf3..c279ba1 100644 --- a/src/__namespace.js +++ b/src/__namespace.js @@ -1,4 +1,5 @@ /** * @ignore */ +window.wikibase = window.wikibase || {}; wikibase.serialization = wikibase.serialization || {};