diff --git a/karma.conf.js b/karma.conf.js index fcdf9beb..3a3ef675 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,10 +1,15 @@ +// Karma configuration +// https://karma-runner.github.io/5.2/config/configuration-file.html module.exports = config => { config.set({ + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha', 'chai', 'commonjs'], - reporters: ['mocha'], - mochaReporter: { - showDiff: true - }, + + // list of files / patterns to load in the browser files: [ 'dist/htmlparser2.js', 'lib/*.js', @@ -12,12 +17,70 @@ module.exports = config => { 'test/client/*.js', 'test/helpers/*.js' ], + + // list of files / patterns to exclude exclude: ['lib/html-to-dom-server.js'], - browsers: ['Chrome'], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { 'dist/**/*.js': ['commonjs'], 'lib/**/*.js': ['commonjs'], 'test/**/*.js': ['commonjs'] + }, + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['mocha', 'progress'], + + // web server port + port: 9876, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + // Start these browsers, currently available: + // - Chrome + // - ChromeCanary + // - Firefox + // - Opera (has to be installed with `npm install karma-opera-launcher`) + // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`) + // - PhantomJS + // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`) + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['Chrome'], + + // If browser does not capture in given timeout [ms], kill it + captureTimeout: 60000, + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity, + + // Client options + client: { + mocha: { + // change Karma's `debug.html` to the Mocha web reporter + reporter: 'html' + } + }, + + // Mocha reporter options + // https://www.npmjs.com/package/karma-mocha-reporter + mochaReporter: { + showDiff: true } }); }; diff --git a/test/client/index.js b/test/client/index.js index 15a049a7..7d507951 100644 --- a/test/client/index.js +++ b/test/client/index.js @@ -1,21 +1,23 @@ var assert = window.chai.assert; var htmlCases = require('../cases/html'); -var htmlparser = require('../../dist/htmlparser2'); -var parser = require('../../lib/html-to-dom-client'); +var serverParser = require('../../dist/htmlparser2').parseDOM; +var clientParser = require('../../lib/html-to-dom-client'); var helpers = require('../helpers'); describe('client parser', function () { - helpers.throwsError(parser, assert); - helpers.runTests(htmlCases, parser, htmlparser.parseDOM, assert); + helpers.throwsError(clientParser, assert); + helpers.runTests(htmlCases, clientParser, serverParser, assert); - it.skip('performance', function () { - var html = '