Skip to content

Commit

Permalink
merged node/browser tests into one codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
roll committed Apr 15, 2017
1 parent 93dfd6f commit 3696312
Show file tree
Hide file tree
Showing 22 changed files with 245 additions and 856 deletions.
26 changes: 12 additions & 14 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
"es2015"
],
"plugins": [
"transform-es2015-arrow-functions",
"transform-es2015-for-of",
"transform-es2015-literals",
"transform-es2015-shorthand-properties",
"transform-es2015-modules-commonjs",
"transform-es2015-classes",
[
"transform-es2015-template-literals",
{
"loose": true,
"spec": true
}
],
"transform-async-to-generator"
]
"transform-es2017-object-entries",
"transform-async-to-generator",
"transform-object-rest-spread",
"transform-decorators-legacy",
"transform-export-extensions",
"transform-class-properties"
],
"env": {
"testing": {
"plugins": ["istanbul"]
}
}
}
16 changes: 14 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ rules:
- warn
- smart
no-unused-vars:
- warn
- error
no-param-reassign:
- warn
- off
no-cond-assign:
- error
- except-parens
arrow-parens:
- error
- as-needed
object-curly-spacing:
- off
no-underscore-dangle:
- off
class-methods-use-this:
Expand All @@ -52,3 +54,13 @@ rules:
no-restricted-syntax:
- error
- WithStatement
no-unused-expressions:
- off
func-names:
- off
space-before-function-paren:
- off
import/no-dynamic-require:
- off
import/newline-after-import:
- off
16 changes: 16 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"lines": 70,
"check-coverage": true,
"include": [
"src/**/*.js"
],
"extension": [
".js"
],
"reporter": [
"lcov",
"text"
],
"sourceMap": false,
"instrument": false
}
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,17 @@ language:
node_js

node_js:
- 4
- 6

script:
- npm run build:dist:test
- npm run test

after_script:
- "node_modules/.bin/babel-node node_modules/.bin/babel-istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"

before_deploy:
- npm run build
- npm run coveralls

deploy:
provider: npm
email: "eskarev@gmail.com"
email: eskarev@gmail.com
skip_cleanup: true
on:
tags: true
Expand Down
25 changes: 25 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const webpackConfig = require('./webpack.config.js')
delete webpackConfig.entry

// Base

const karmaConfig = (config) => {
config.set({
singleRun: true,
browsers: ['PhantomJS'],
frameworks: ['mocha', 'sinon-chai'],
files: ['test/karma.opts'],
reporters: ['spec'],
preprocessors: {
'test/karma.opts': ['webpack'],
},
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
})
}

// Module API

module.exports = karmaConfig
84 changes: 47 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
"name": "datapackage",
"version": "0.8.3",
"description": "Utilities to work with Data Packages as defined on specs.frictionlessdata.io",
"keywords": [
"data package",
"frictionless data",
"open data",
"open knowledge"
],
"license": "MIT",
"main": "lib/index.js",
"engines": {
"node": ">=4"
},
Expand All @@ -16,12 +12,30 @@
"dist",
"src"
],
"main": "lib/index.js",
"scripts": {
"build": "npm run build:lib && npm run build:dist && npm run build:dist-min",
"build:lib": "babel src --out-dir lib --copy-files",
"build:dist": "webpack --progress --hide-modules",
"build:dist-min": "NODE_ENV=production webpack --progress --hide-modules",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"lint": "eslint src test",
"prepublish": "npm run build",
"prepush": "npm run test",
"pretest": "npm run lint",
"profiles": "npm run profiles:registry && npm run profiles:data-package && npm run profiles:tabular-data-package && npm run profiles:fiscal-data-package",
"profiles:registry": "wget -O src/profiles/registry.json https://specs.frictionlessdata.io/schemas/registry.json",
"profiles:data-package": "wget -O src/profiles/data-package.json https://specs.frictionlessdata.io/schemas/data-package.json",
"profiles:tabular-data-package": "wget -O src/profiles/tabular-data-package.json https://specs.frictionlessdata.io/schemas/tabular-data-package.json",
"profiles:fiscal-data-package": "wget -O src/profiles/fiscal-data-package.json https://specs.frictionlessdata.io/schemas/fiscal-data-package.json",
"test": "npm run test:node && npm run test:browser",
"test:node": "NODE_ENV=testing nyc mocha",
"test:browser": "NODE_ENV=testing karma start"
},
"dependencies": {
"isomorphic-fetch": "^2.2.1",
"json-lint": "^0.1.0",
"jsontableschema": "^0.2.2",
"lodash": "^4.13.1",
"tableschema": "^1.0.0-alpha.3",
"tv4": "^1.2.7"
},
"devDependencies": {
Expand All @@ -30,14 +44,14 @@
"babel-cli": "^6.8.0",
"babel-istanbul": "^0.8.0",
"babel-loader": "^6.2.1",
"babel-plugin-istanbul": "^3.1.2",
"babel-plugin-transform-async-to-generator": "^6.16.0",
"babel-plugin-transform-es2015-arrow-functions": "^6.8.0",
"babel-plugin-transform-es2015-classes": "^6.8.0",
"babel-plugin-transform-es2015-for-of": "^6.8.0",
"babel-plugin-transform-es2015-literals": "^6.8.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.8.0",
"babel-plugin-transform-es2015-shorthand-properties": "^6.8.0",
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"babel-plugin-transform-class-properties": "^6.22.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-es2015-modules-commonjs": "^6.22.0",
"babel-plugin-transform-es2017-object-entries": "0.0.3",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.20.2",
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.6.0",
"chai": "^2.3.0",
Expand All @@ -51,34 +65,25 @@
"eslint-plugin-jsx-a11y": "2.2.3",
"eslint-plugin-react": "^6.8.0",
"fetch-mock": "^4.5.0",
"husky": "^0.13.3",
"jsdom": "^9.9.1",
"json-loader": "^0.5.4",
"karma": "^1.6.0",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sinon-chai": "^1.2.4",
"karma-spec-reporter": "0.0.26",
"karma-webpack": "^2.0.2",
"mocha": "^2.4.5",
"mocha-lcov-reporter": "^1.2.0",
"nock": "^9.0.2",
"nyc": "^10.2.0",
"sinon": "^2.1.0",
"sinon-chai": "^2.9.0",
"superagent-mock": "^1.1.0",
"webpack": "^1.12.11",
"webpack-dev-server": "^1.14.1",
"webpack": "^2.2.0",
"webpack-dev-server": "^2.2.0",
"webpack-merge": "^2.4.0"
},
"scripts": {
"build:lib": "babel src --out-dir lib --copy-files",
"build:dist": "webpack",
"build:dist:min": "NODE_ENV=production webpack",
"build:dist:test": "NODE_ENV=test webpack",
"build:dist:test:watch": "NODE_ENV=test webpack --watch",
"build": "npm run build:lib && npm run build:dist && npm run build:dist:min",
"profiles": "npm run profiles:registry && npm run profiles:data-package && npm run profiles:tabular-data-package && npm run profiles:fiscal-data-package",
"profiles:registry": "wget -O src/profiles/registry.json https://specs.frictionlessdata.io/schemas/registry.json",
"profiles:data-package": "wget -O src/profiles/data-package.json https://specs.frictionlessdata.io/schemas/data-package.json",
"profiles:tabular-data-package": "wget -O src/profiles/tabular-data-package.json https://specs.frictionlessdata.io/schemas/tabular-data-package.json",
"profiles:fiscal-data-package": "wget -O src/profiles/fiscal-data-package.json https://specs.frictionlessdata.io/schemas/fiscal-data-package.json",
"pretest": "npm run lint",
"lint": "eslint scripts src test",
"test": "babel-node ./node_modules/.bin/babel-istanbul cover _mocha -- test/",
"test:node": "babel-node ./node_modules/.bin/babel-istanbul cover _mocha -- test/node/",
"test:browser": "babel-node ./node_modules/.bin/babel-istanbul cover _mocha -- test/browser"
},
"author": {
"name": "Open Knowledge",
"email": "info@okfn.org",
Expand All @@ -90,5 +95,10 @@
"type": "git",
"url": "https://github.com/frictionlessdata/datapackage-js.git"
},
"license": "MIT"
"keywords": [
"data package",
"frictionless data",
"open data",
"open knowledge"
]
}
2 changes: 1 addition & 1 deletion src/datapackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export default class DataPackage {
let pathErrors = []
if (resourceObject.type !== 'inline') {
try {
const valid = resourceObject._validPaths
resourceObject._validPaths
} catch (err) {
pathErrors = err
}
Expand Down
4 changes: 1 addition & 3 deletions src/profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default class Profiles {
try {
// Dynamic require for webpack to bundle all json files from ./schemas
// so they can be required in the browser
resolve(JSON.stringify(require('./schemas/' + filePath + '.json')))
resolve(JSON.stringify(require(`./schemas/${filePath}.json`)))
} catch (err) {
reject(err)
}
Expand All @@ -193,5 +193,3 @@ export default class Profiles {
return Utils.readFileOrURL(filePath)
}
}

/* eslint import/no-dynamic-require: off, prefer-template: off */
2 changes: 1 addition & 1 deletion src/resource.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import url from 'url'
import path from 'path'
import jts from 'jsontableschema'
import jts from 'tableschema'

import Utils from './utils'

Expand Down
6 changes: 0 additions & 6 deletions test/browser/buildIndex.js

This file was deleted.

Loading

0 comments on commit 3696312

Please sign in to comment.