Skip to content

Commit

Permalink
feat(karma): test bson in the browser
Browse files Browse the repository at this point in the history
* revert back to previous version of browser testing

* should run on travis now

* package lock

* updated package.json to not need build

* remove buffers necessary for wrong package.json version
  • Loading branch information
Sophie Saskin authored and mbroadst committed Jul 16, 2018
1 parent ae8afd1 commit cd593ca
Show file tree
Hide file tree
Showing 17 changed files with 5,332 additions and 1,241 deletions.
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ sudo: false
dist: trusty

language: node_js
node_js:
- 4
- 6
- 8
- 10

cache:
yarn: true
directories:
- node_modules

node_js:
- 4
- 6
- 8
- 10
script:
- npm run-script test-node
- if [[ $(node --version) != v4* ]] ; then npm run-script test-browser; fi
66 changes: 66 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'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;

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

0 comments on commit cd593ca

Please sign in to comment.