use nyc for coverage (#3652)

* use nyc for coverage

* removes unnecessary logss

* Disable RedisCacheAdapter tests when not in specific environment
This commit is contained in:
Florent Vilmart
2017-03-20 12:58:36 -04:00
committed by Arthur Cinader
parent eeb3a7028d
commit f3765e0b8e
10 changed files with 38 additions and 15 deletions

View File

@@ -1,2 +1,3 @@
lib/* lib
coverage/* coverage

1
.gitignore vendored
View File

@@ -13,6 +13,7 @@ lib-cov
# Coverage directory used by tools like istanbul # Coverage directory used by tools like istanbul
coverage coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt .grunt

View File

@@ -1,2 +0,0 @@
instrumentation:
excludes: ["**/spec/**"]

11
.nycrc Normal file
View File

@@ -0,0 +1,11 @@
{
"reporter": [
"lcov",
"text-summary"
],
"exclude": [
"**/spec/**",
"lib/"
]
}

View File

@@ -18,7 +18,7 @@ before_script:
- psql -c 'CREATE EXTENSION postgis_topology;' -U postgres -d parse_server_postgres_adapter_test_database - psql -c 'CREATE EXTENSION postgis_topology;' -U postgres -d parse_server_postgres_adapter_test_database
env: env:
global: global:
- COVERAGE_OPTION='./node_modules/.bin/istanbul cover' - COVERAGE_OPTION='./node_modules/.bin/nyc'
matrix: matrix:
- MONGODB_VERSION=3.0.8 - MONGODB_VERSION=3.0.8
- MONGODB_VERSION=3.2.6 - MONGODB_VERSION=3.2.6

View File

@@ -44,7 +44,6 @@
"ws": "2.2.1" "ws": "2.2.1"
}, },
"devDependencies": { "devDependencies": {
"babel-cli": "6.24.0", "babel-cli": "6.24.0",
"babel-core": "6.23.1", "babel-core": "6.23.1",
"babel-eslint": "^7.1.1", "babel-eslint": "^7.1.1",
@@ -59,11 +58,11 @@
"eslint": "^3.16.1", "eslint": "^3.16.1",
"eslint-plugin-flowtype": "^2.25.0", "eslint-plugin-flowtype": "^2.25.0",
"gaze": "1.1.1", "gaze": "1.1.1",
"istanbul": "1.0.0-alpha.1",
"jasmine": "2.5.3", "jasmine": "2.5.3",
"jasmine-spec-reporter": "^3.1.0", "jasmine-spec-reporter": "^3.1.0",
"mongodb-runner": "3.4.0", "mongodb-runner": "3.4.0",
"nodemon": "1.11.0", "nodemon": "1.11.0",
"nyc": "^10.1.2",
"request-promise": "4.2.0" "request-promise": "4.2.0"
}, },
"scripts": { "scripts": {
@@ -73,8 +72,8 @@
"pretest": "npm run lint", "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": "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", "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": "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/istanbul/lib/cli.js cover ./node_modules/jasmine/bin/jasmine.js", "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", "start": "node ./bin/parse-server",
"prepublish": "npm run build" "prepublish": "npm run build"
}, },

View File

@@ -16,6 +16,7 @@
"notEqual": true, "notEqual": true,
"it_exclude_dbs": true, "it_exclude_dbs": true,
"describe_only_db": true, "describe_only_db": true,
"describe_only": true,
"on_db": true, "on_db": true,
"defaultConfiguration": true, "defaultConfiguration": true,
"expectSuccess": true, "expectSuccess": true,

View File

@@ -755,14 +755,12 @@ describe('Parse.ACL', () => {
user2.set("password", "burger"); user2.set("password", "burger");
return user2.signUp(); return user2.signUp();
}).then(() => { }).then(() => {
console.log(user2.getSessionToken());
return object.destroy({sessionToken: user2.getSessionToken() }); return object.destroy({sessionToken: user2.getSessionToken() });
}).then((res) => { }).then(() => {
console.log(res);
fail('should not be able to destroy the object'); fail('should not be able to destroy the object');
done(); done();
}, (err) => { }, (err) => {
console.error(err); expect(err).not.toBeUndefined();
done(); done();
}); });
}); });

View File

@@ -1,6 +1,12 @@
var RedisCacheAdapter = require('../src/Adapters/Cache/RedisCacheAdapter').default; 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 KEY = 'hello';
var VALUE = 'world'; var VALUE = 'world';

View File

@@ -419,6 +419,14 @@ global.describe_only_db = db => {
} }
} }
global.describe_only = (validator) =>{
if (validator()) {
return describe;
} else {
return xdescribe;
}
};
var libraryCache = {}; var libraryCache = {};
jasmine.mockLibrary = function(library, name, mock) { jasmine.mockLibrary = function(library, name, mock) {