Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test coverage #62

Merged
merged 2 commits into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 0 additions & 50 deletions .babelrc

This file was deleted.

3 changes: 3 additions & 0 deletions .gitattributes
@@ -0,0 +1,3 @@
dist/** -diff
yarn.lock -diff

8 changes: 1 addition & 7 deletions .nycrc
Expand Up @@ -3,15 +3,9 @@
"sourceMap": false,
"instrument": false,
"include": [
"src/**/*.js"
"modules/**/*.js"
],
"exclude": [
"test/**/*.js"
],
"reporter": [
"lcov",
"html",
"text",
"cobertura"
]
}
63 changes: 63 additions & 0 deletions babel.config.js
@@ -0,0 +1,63 @@
const TARGETS = {
"chrome": "60",
"edge": "15",
"firefox": "53",
"ios": "10.3",
"safari": "10.1",
"node": "8"
};

const CONFIG = {
default: {
"presets": [
[ "@babel/env", {
"targets": TARGETS
}]
],
"plugins": [
"version-inline",
"@babel/proposal-class-properties"
],
}
};

CONFIG.es6 = Object.assign({}, CONFIG.default, {
"presets": [
[ "@babel/env", {
"targets": TARGETS,
"modules": false
}]
]
});

CONFIG.esm = Object.assign({}, CONFIG.default, {
"presets": [
[ "@babel/env", {
"modules": false
}]
]
});

CONFIG.es5 = Object.assign({}, CONFIG.default, {
"presets": [
[ "@babel/env", {
"modules": "commonjs"
}]
],
});

CONFIG.cover = Object.assign({}, CONFIG.default);
CONFIG.cover.plugins = CONFIG.cover.plugins.concat(['istanbul']);

module.exports = function getConfig(api) {

// eslint-disable-next-line
var env = api.cache(() => process.env.BABEL_ENV || process.env.NODE_ENV);

const config = CONFIG[env] || CONFIG.default;
// Uncomment to debug
console.error(env, config.plugins);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out before merging

return config;
};

module.exports.config = CONFIG.es6;
3 changes: 0 additions & 3 deletions modules/builder/.babelrc

This file was deleted.

9 changes: 5 additions & 4 deletions modules/builder/package.json
Expand Up @@ -17,10 +17,11 @@
},
"scripts": {
"clean": "rm -fr dist && mkdir -p dist",
"build-es6": "BABEL_ENV=es6 babel src --out-dir dist/es6 --source-maps --ignore 'node_modules/'",
"build-esm": "BABEL_ENV=esm babel src --out-dir dist/esm --source-maps --ignore 'node_modules/'",
"build-es5": "BABEL_ENV=es5 babel src --out-dir dist/es5 --source-maps --ignore 'node_modules/'",
"build": "npm run clean && npm run build-es6 && npm run build-esm && npm run build-es5"
"build-es6": "BABEL_ENV=es6 babel src --config-file ../../babel.config.js --out-dir dist/es6 --source-maps --ignore 'node_modules/'",
"build-esm": "BABEL_ENV=esm babel src --config-file ../../babel.config.js --out-dir dist/esm --source-maps --ignore 'node_modules/'",
"build-es5": "BABEL_ENV=es5 babel src --config-file ../../babel.config.js --out-dir dist/es5 --source-maps --ignore 'node_modules/'",
"build": "npm run clean && npm run build-es6 && npm run build-esm && npm run build-es5",
"cover": "NODE_ENV=test BABEL_ENV=cover npx nyc node ../../test/start.js cover"
},
"engines": {
"node": ">= 8",
Expand Down
3 changes: 0 additions & 3 deletions modules/parser/.babelrc

This file was deleted.

9 changes: 5 additions & 4 deletions modules/parser/package.json
Expand Up @@ -23,10 +23,11 @@
},
"scripts": {
"clean": "rm -fr dist && mkdir -p dist",
"build-es6": "BABEL_ENV=es6 babel src --out-dir dist/es6 --source-maps --ignore 'node_modules/'",
"build-esm": "BABEL_ENV=esm babel src --out-dir dist/esm --source-maps --ignore 'node_modules/'",
"build-es5": "BABEL_ENV=es5 babel src --out-dir dist/es5 --source-maps --ignore 'node_modules/'",
"build": "npm run clean && npm run build-es6 && npm run build-esm && npm run build-es5"
"build-es6": "BABEL_ENV=es6 babel src --config-file ../../babel.config.js --out-dir dist/es6 --source-maps --ignore 'node_modules/'",
"build-esm": "BABEL_ENV=esm babel src --config-file ../../babel.config.js --out-dir dist/esm --source-maps --ignore 'node_modules/'",
"build-es5": "BABEL_ENV=es5 babel src --config-file ../../babel.config.js --out-dir dist/es5 --source-maps --ignore 'node_modules/'",
"build": "npm run clean && npm run build-es6 && npm run build-esm && npm run build-es5",
"cover": "NODE_ENV=test BABEL_ENV=cover npx nyc node ../../test/start.js cover"
},
"engines": {
"node": ">= 8",
Expand Down
2 changes: 1 addition & 1 deletion modules/schema/package.json
Expand Up @@ -12,7 +12,7 @@
"walk": "^2.3.14"
},
"scripts": {
"build": "echo \"No transpilation needed\"",
"build": "echo \"No transpilation needed for @xviz/schema\"",
"check": "node validate.js"
},
"private": true
Expand Down
44 changes: 22 additions & 22 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "xviz",
"description": "Utility library for handling XVIZ protocol",
"description": "Libraries for encoding, validation and decoding of the XVIZ protocol",
"version": "0.0.1",
"repository": {
"type": "git",
Expand All @@ -9,51 +9,51 @@
"workspaces": [
"modules/*"
],
"scripts": {
"bootstrap": "scripts/bootstrap.sh",
"bench": "node test/start bench",
"build": "lerna run build",
"flow": "flow check",
"cover": "NODE_ENV=cover nyc node test/start",
"lint": "scripts/lint.sh",
"publish": "scripts/publish.sh",
"test": "scripts/test.sh",
"test-browser": "webpack-dev-server --config test/webpack.config.js --hot --open"
},
"devDependencies": {
"@babel/cli": "^7.0.0-beta",
"@babel/core": "^7.0.0-beta",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta",
"@babel/preset-env": "^7.0.0-beta",
"@babel/register": "^7.0.0-beta",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"ajv": "^6.5.2",
"ajv-cli": "^3.0.0",
"babel-eslint": "^7.1.1",
"babel-loader": "^8.0.0-beta",
"babel-plugin-istanbul": "^4.1.1",
"babel-loader": "^8.0.0",
"babel-plugin-istanbul": "^5.0.0",
"babel-plugin-version-inline": "^1.0.0",
"babel-preset-minify": "^0.4.0-alpha.caaefb4c",
"coveralls": "^2.13.0",
"eslint": "^4.13.1",
"eslint-config-prettier": "^2.9.0",
"eslint-config-uber-es2015": "^3.1.2",
"html-webpack-plugin": "^3.2.0",
"lerna": "^2.9.1",
"module-alias": "^2.0.0",
"nyc": "^10.2.0",
"nyc": "^13.0.0",
"pre-commit": "^1.2.2",
"prettier": "^1.9.2",
"prettier-check": "^2.0.0",
"puppeteer": "^1.7.0",
"source-map-loader": "^0.2.1",
"tap-browser-color": "^0.1.2",
"tape": "^4.9",
"walk": "^2.3.14",
"tape-catch": "^1.0.4",
"walk": "^2.3.14",
"webpack": "^4.3.0",
"webpack-cli": "^2.0.13",
"webpack-dev-server": "^3.1.1",
"webworkify-webpack": "^2.0.0"
},
"scripts": {
"bootstrap": "scripts/bootstrap.sh",
"bench": "NODE_ENV=test node test/start bench",
"build": "lerna run build",
"flow": "flow check",
"cover": "nyc npm run test",
"lint": "scripts/lint.sh",
"publish": "scripts/publish.sh",
"test": "npm run lint && NODE_ENV=test node test/start test",
"test-browser": "webpack-dev-server --config test/webpack.config.js --hot --open"
},
"engines": {
"node": ">= 8",
"npm": ">= 5",
Expand Down
81 changes: 81 additions & 0 deletions scripts/test.sh
@@ -0,0 +1,81 @@
#!/bin/sh
# Automated tests

set -e

BASEDIR=$(dirname "$0")

MODE=$1

run_lint() {
npm run lint
# markdownlint docs
}

run_full_test() {
run_lint
node test/start.js test src
node test/start.js test browser
# node test/start.js render
}

case $MODE in
"")
run_full_test;
echo "Ran 'full' test by default. Other options:"
echo "test [ 'full' | fast' | 'bench' | 'ci' | 'cover' | 'examples' | 'lint' | size-es6' ]"
break;;

"full")
run_full_test;
break;;

"lint")
run_lint
break;;

"fast")
node test/start.js fast
break;;

"cover")
echo "HERE"
# Seems to need to be run from each package.json root...
(cd $BASEDIR/../modules/parser && NODE_ENV=test BABEL_ENV=cover npx nyc node ../../test/start.js cover)
echo "HERE"
npx nyc report
break;;

"dist")
npm run build
node test/start.js test-dist
break;;

"examples")
node test/node-examples.js
break;;

"bench")
node test/start.js bench
node test/start.js bench-browser
break;;

"size-es6")
npm run build
NODE_ENV=production webpack --config test/webpack.config.js --env.import-nothing --env.es6
break;;

"ci")
# run by Travis CI
node test/start.js bench
$BASEDIR/collect-metrics-fast.sh
npm run cover
(cd $BASEDIR/../modules/core && npm run build-es6)
break;;


*)
# default test
node test/start.js $MODE
break;;
esac
33 changes: 32 additions & 1 deletion test/browser.js
@@ -1,2 +1,33 @@
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

require('tap-browser-color')();
require('./index');

const test = require('tape');

const {callExposedFunction} = require('probe.gl/test-utils');

test.onFinish(() => callExposedFunction('testDone', {success: true}));
test.onFailure(() => callExposedFunction('testDone', {success: false}));

test('Browser tests', t => {
require('./index');
t.end();
});
2 changes: 1 addition & 1 deletion test/index.js
@@ -1,4 +1,4 @@
// Set up a configuration (TODO/OSS - this should be a neutral config)
import './modules/builder';
import './modules/parser';
import './modules/schema';
// import './modules/schema';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this breaking something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlisee @twojtasz The schema tests disable our other tests, so commenting them out for now in order to get progress on coverage.