Skip to content

Commit

Permalink
feat(bson): test bson in browser
Browse files Browse the repository at this point in the history
Add support for running bson tests in the browser
via Karma.

Fixes NODE-1504
  • Loading branch information
rweinberger authored and Sophie Saskin committed Jul 11, 2018
1 parent 3620ef8 commit 223fbdf
Show file tree
Hide file tree
Showing 22 changed files with 5,621 additions and 1,443 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ cache:
directories:
- node_modules

before_script:
- "sudo chown root /opt/google/chrome/chrome-sandbox"
- "sudo chmod 4755 /opt/google/chrome/chrome-sandbox"
- "npm run build"

node_js:
- 4
- 6
Expand Down
63 changes: 63 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict';

const scenariosPlugin = require('./tools/scenarios-plugin');
const jsonPlugin = require('rollup-plugin-json');
const nodeGlobals = require('rollup-plugin-node-globals');
const nodeBuiltins = require('rollup-plugin-node-builtins');
const commonjs = require('rollup-plugin-commonjs');
const nodeResolve = require('rollup-plugin-node-resolve');

const rollupPlugins = [
scenariosPlugin(),
nodeResolve({
browser: true,
preferBuiltins: false
}),
commonjs({
namedExports: {
'node_modules/buffer/index.js': ['isBuffer']
}
}),
nodeBuiltins(),
nodeGlobals(),
jsonPlugin()
];

const rollupConfig = {
plugins: rollupPlugins,
output: {
format: 'iife',
name: 'BSONtest',
exports: 'named'
}
};

const onwarn = warning => {
if (warning.code === 'CIRCULAR_DEPENDENCY' || warning.code === 'EVAL') return;
console.warn(warning.toString());
};

rollupConfig.onwarn = onwarn;

// Karma configuration
// Generated on Thu Jun 28 2018 14:24:01 GMT-0400 (EDT)

module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['mocha'],
reporters: ['mocha'],
files: [{ pattern: 'test/node/!(bson_node_only_test).js', watched: false }],
preprocessors: {
'test/node/!(bson_node_only_test).js': 'rollup'
},
rollupPreprocessor: rollupConfig,
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: true,
concurrency: Infinity
});
};
Loading

0 comments on commit 223fbdf

Please # to comment.