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

Revamping testing suit. #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -18,9 +18,9 @@ install:
- npm install

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3
- npm run build

script: npm run test:node

after_script:
- npm run coverage:travis
script: npm run test:node && npm run test:browser:coverage
89 changes: 0 additions & 89 deletions Gulpfile.babel.js

This file was deleted.

79 changes: 79 additions & 0 deletions karma.conf.js
@@ -0,0 +1,79 @@
var path = require('path');
module.exports = function (config) {
config.set({

basePath: '.',

frameworks: ['mocha', 'chai', 'sinon'],
singleRun: true, //just run once by default

files: [
'tests.webpack.js', //just load this file instead of individual test files. It will fetch the proper content
],
preprocessors: {
'tests.webpack.js': [ 'webpack', 'sourcemap'] //preprocess with webpack and our sourcemap loader
},

//~ babelPreprocessor: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could clean this

//~ "plugins": [
//~ "transform-runtime",
//~ ["transform-async-to-module-method", {
//~ "module": "bluebird",
//~ "method": "coroutine"
//~ }]
//~ ]
//~ },

webpack: { //kind of a copy of your webpack config
debug:true,
devtool: 'inline-source-map', //just do inline source maps instead of the default
output: {
library: 'gremlin',
libraryTarget: 'umd'
},
module: {
preLoaders: [
// instrument only testing sources with Istanbul
{
test: /\.js$/,
include: path.resolve('src/'),
loader: 'isparta'
}
],
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' }
]
}
},

reporters: ['mocha', 'coverage', 'coveralls'],

coverageReporter: {
type: 'lcov', // lcov or lcovonly are required for generating lcov.info files
dir: 'coverage/'
},

port: 9876,
colors: true,
autoWatch: false,
singleRun: false,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

browsers: ['Firefox'],
plugins: [
'karma-firefox-launcher',
'karma-mocha',
'karma-chai',
'karma-webpack',
'karma-sourcemap-loader',
'karma-mocha-reporter',
'karma-coverage',
'karma-coveralls',
'karma-sinon'
]

});
};
56 changes: 27 additions & 29 deletions package.json
Expand Up @@ -6,14 +6,17 @@
"scripts": {
"build": "babel ./src -d lib",
"build:umd": "NODE_ENV=production webpack src/index.js umd/gremlin.js",
"build:min": "NODE_ENV=production webpack -p src/index.js umd/gremlin.min.js",
"build:min": "NODE_ENV=production webpack -p src/index.js umd/gremlin.min.js --optimize-occurence-order --optimize-dedupe",
"build:watch": "npm run build -- --watch",
"coverage": "babel-node ./node_modules/istanbul/lib/cli.js cover _mocha",
"coverage:travis": "babel-node ./node_modules/istanbul/lib/cli.js cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"examples:browser": "babel-node examples/server",
"examples:node": "babel-node examples/node-example",
"test": "npm run test:node && npm run test:browser",
"test:coverage": "npm run test:node && npm run test:browser:coverage",
"test:node": "mocha ./test --compilers js:babel-register --recursive --reporter spec",
"test:node:watch": "npm run test:node -- --watch"
"test:node:watch": "npm run test:node -- --watch",
"test:browser": "karma start karma.conf.js --single-run --reporters mocha",
"test:browser:coverage": "karma start karma.conf.js --single-run",
"test:browser:debug": "karma start karma.conf.js --reporters mocha"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -41,39 +44,34 @@
"ws": "^0.8.0"
},
"devDependencies": {
"babel-cli": "^6.4.5",
"babel-core": "^6.4.0",
"babel-loader": "^6.2.1",
"babel-cli": "~6.6.5",
"babel-core": "~6.7.2",
"babel-loader": "~6.2.4",
"babel-preset-es2015": "~6.6.0",
"babel-preset-stage-2": "~6.5.0",
"babel-register": "~6.7.2",
"babel-plugin-transform-async-to-module-method": "^6.5.2",
"babel-plugin-transform-runtime": "^6.5.2",
"babel-preset-es2015": "^6.3.13",
"babel-preset-stage-2": "^6.3.13",
"babel-register": "^6.3.13",
"babelify": "^5.0.4",
"bluebird": "^3.3.3",
"browserify": "^9.0.3",
"chai": "^2.1.1",
"finalhandler": "^0.1.0",
"gulp": "^3.9.0",
"gulp-buffer": "0.0.2",
"gulp-mocha": "^2.0.0",
"gulp-rename": "^1.2.0",
"gulp-size": "^1.0.0",
"gulp-uglify": "^0.3.1",
"istanbul": "^0.4.2",
"istanbul-coveralls": "^1.0.3",
"karma": "^0.12.31",
"karma-browserify": "^0.2.1",
"chai": "^3.5.0",
"isparta-loader": "^2.0.0",
"sinon": "^1.17.3",
"karma": "^0.13.22",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^0.1.4",
"karma-firefox-launcher": "^0.1.3",
"karma-mocha": "^0.1.10",
"karma-safari-launcher": "^0.1.1",
"mocha": "^1.21.4",
"mocha-lcov-reporter": "^1.2.0",
"karma-coverage": "^0.5.5",
"karma-coveralls": "^1.1.2",
"karma-firefox-launcher": "^0.1.7",
"karma-mocha": "^0.2.2",
"karma-mocha-reporter": "^2.0.0",
"karma-sinon": "^1.0.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.7.0",
"mocha": "^2.4.5",
"serve-static": "^1.5.3",
"vinyl-source-stream": "^1.0.0",
"webpack": "^1.12.11",
"webpack": "^1.12.14",
"yargs": "^1.3.1"
}
}
4 changes: 0 additions & 4 deletions src/.babelrc

This file was deleted.

25 changes: 25 additions & 0 deletions test/GremlinClientTest.js
@@ -0,0 +1,25 @@
import Client from '../src/GremlinClient';

describe('GremlinClient', () => {
describe('.construct()', () => {

it('should allow setting the `port` option', () => {
const client = new Client(8183);
client.on('error', (err) => {}); //catch error
client.port.should.equal(8183);
});

it('should allow setting the `host` option', () => {
const client = new Client(8182, "otherhost");
client.on('error', (err) => {}); //catch error
client.host.should.equal('otherhost');
});

it('should allow setting session option', () => {
const client = new Client(8182, "localhost", {session:true});
client.port.should.equal(8182);
client.host.should.equal('localhost');
client.options.session.should.equal(true);
});
});
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions tests.webpack.js
@@ -0,0 +1,6 @@
//tell karma which files to load.
var testContext = require.context('./test', true, /Test\.js$/);
testContext.keys().forEach(testContext);

var allContext = require.context('./src', true, /\.js$/);
allContext.keys().forEach(allContext);