From f3765e0b8eb148e2e1fbbda70769a4b74705adc7 Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Mon, 20 Mar 2017 12:58:36 -0400 Subject: [PATCH] use nyc for coverage (#3652) * use nyc for coverage * removes unnecessary logss * Disable RedisCacheAdapter tests when not in specific environment --- .eslintignore | 5 +++-- .gitignore | 1 + .istanbul.yml | 2 -- .nycrc | 11 +++++++++++ .travis.yml | 2 +- package.json | 7 +++---- spec/.eslintrc.json | 1 + spec/ParseACL.spec.js | 6 ++---- spec/RedisCacheAdapter.spec.js | 10 ++++++++-- spec/helper.js | 8 ++++++++ 10 files changed, 38 insertions(+), 15 deletions(-) delete mode 100644 .istanbul.yml create mode 100644 .nycrc diff --git a/.eslintignore b/.eslintignore index af229265..b7c67dd1 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ -lib/* -coverage/* +lib +coverage + diff --git a/.gitignore b/.gitignore index 763f38be..4e4ee21c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ lib-cov # Coverage directory used by tools like istanbul coverage +.nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt diff --git a/.istanbul.yml b/.istanbul.yml deleted file mode 100644 index c0890a3f..00000000 --- a/.istanbul.yml +++ /dev/null @@ -1,2 +0,0 @@ -instrumentation: - excludes: ["**/spec/**"] diff --git a/.nycrc b/.nycrc new file mode 100644 index 00000000..60afab1c --- /dev/null +++ b/.nycrc @@ -0,0 +1,11 @@ +{ + "reporter": [ + "lcov", + "text-summary" + ], + "exclude": [ + "**/spec/**", + "lib/" + ] +} + diff --git a/.travis.yml b/.travis.yml index 183c3145..989d765e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ before_script: - psql -c 'CREATE EXTENSION postgis_topology;' -U postgres -d parse_server_postgres_adapter_test_database env: global: - - COVERAGE_OPTION='./node_modules/.bin/istanbul cover' + - COVERAGE_OPTION='./node_modules/.bin/nyc' matrix: - MONGODB_VERSION=3.0.8 - MONGODB_VERSION=3.2.6 diff --git a/package.json b/package.json index e3c19a9e..54e1b177 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,6 @@ "ws": "2.2.1" }, "devDependencies": { - "babel-cli": "6.24.0", "babel-core": "6.23.1", "babel-eslint": "^7.1.1", @@ -59,11 +58,11 @@ "eslint": "^3.16.1", "eslint-plugin-flowtype": "^2.25.0", "gaze": "1.1.1", - "istanbul": "1.0.0-alpha.1", "jasmine": "2.5.3", "jasmine-spec-reporter": "^3.1.0", "mongodb-runner": "3.4.0", "nodemon": "1.11.0", + "nyc": "^10.1.2", "request-promise": "4.2.0" }, "scripts": { @@ -73,8 +72,8 @@ "pretest": "npm run lint", "test": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=3.2.6} MONGODB_STORAGE_ENGINE=mmapv1 NODE_ENV=test TESTING=1 $COVERAGE_OPTION jasmine", "test:win": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=3.2.6} MONGODB_STORAGE_ENGINE=mmapv1 NODE_ENV=test TESTING=1 jasmine", - "coverage": "cross-env COVERAGE_OPTION='./node_modules/.bin/istanbul cover' npm test", - "coverage:win": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=3.2.6} MONGODB_STORAGE_ENGINE=mmapv1 NODE_ENV=test TESTING=1 node ./node_modules/istanbul/lib/cli.js cover ./node_modules/jasmine/bin/jasmine.js", + "coverage": "cross-env COVERAGE_OPTION='./node_modules/.bin/nyc' npm test", + "coverage:win": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=3.2.6} MONGODB_STORAGE_ENGINE=mmapv1 NODE_ENV=test TESTING=1 node ./node_modules/.bin/nyc ./node_modules/jasmine/bin/jasmine.js", "start": "node ./bin/parse-server", "prepublish": "npm run build" }, diff --git a/spec/.eslintrc.json b/spec/.eslintrc.json index 0f826391..32b0a12f 100644 --- a/spec/.eslintrc.json +++ b/spec/.eslintrc.json @@ -16,6 +16,7 @@ "notEqual": true, "it_exclude_dbs": true, "describe_only_db": true, + "describe_only": true, "on_db": true, "defaultConfiguration": true, "expectSuccess": true, diff --git a/spec/ParseACL.spec.js b/spec/ParseACL.spec.js index f28ea5c0..aedeb247 100644 --- a/spec/ParseACL.spec.js +++ b/spec/ParseACL.spec.js @@ -755,14 +755,12 @@ describe('Parse.ACL', () => { user2.set("password", "burger"); return user2.signUp(); }).then(() => { - console.log(user2.getSessionToken()); return object.destroy({sessionToken: user2.getSessionToken() }); - }).then((res) => { - console.log(res); + }).then(() => { fail('should not be able to destroy the object'); done(); }, (err) => { - console.error(err); + expect(err).not.toBeUndefined(); done(); }); }); diff --git a/spec/RedisCacheAdapter.spec.js b/spec/RedisCacheAdapter.spec.js index 9e941eff..8707da25 100644 --- a/spec/RedisCacheAdapter.spec.js +++ b/spec/RedisCacheAdapter.spec.js @@ -1,6 +1,12 @@ var RedisCacheAdapter = require('../src/Adapters/Cache/RedisCacheAdapter').default; - -describe('RedisCacheAdapter', function() { +/* +To run this test part of the complete suite +set PARSE_SERVER_TEST_CACHE='redis' +and make sure a redis server is available on the default port + */ +describe_only(() => { + return process.env.PARSE_SERVER_TEST_CACHE === 'redis'; +})('RedisCacheAdapter', function() { var KEY = 'hello'; var VALUE = 'world'; diff --git a/spec/helper.js b/spec/helper.js index 854bbd18..7e52f175 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -419,6 +419,14 @@ global.describe_only_db = db => { } } +global.describe_only = (validator) =>{ + if (validator()) { + return describe; + } else { + return xdescribe; + } +}; + var libraryCache = {}; jasmine.mockLibrary = function(library, name, mock) {