1.3.3 • Published 2 years ago

karma-webpack-bundle v1.3.3

Weekly downloads
19
License
MIT
Repository
github
Last release
2 years ago

Karma Webpack Bundle

A personalized bundle of karma libraries and configs

npm deps size vulnerabilities license

Installation

npm install karma-webpack-bundle --save-dev

benchSettings : object

Settings object for karma-benchmark. I don't see any need for benchmarks to run for 5 seconds, so I've provided settings that run the benchmark for 200ms.

Properties

NameTypeDefault
maxTimenumber0.2
minTimenumber0.2
minSamplesnumber1
delaynumber0
asyncbooleantrue

Example

const {benchSettings} = require('karma-webpack-bundle');

benchmark('how fast is this', () => {
    [1, 2, 3].map((x) => x * 2);
}, benchSettings);

eslintrcBench : object

An eslint config object that overrides various rules from the main config for bench files.

Example
Create a file in your bench directory called .eslintrc.cjs:

const { eslintrcBench } = require('karma-webpack-bundle');

module.exports = eslintrcBench;

eslintrc : object

An eslint config object intended to live in the root of your project.

Example
Create a file in the root of your project called .eslintrc.cjs:

const { eslintrc } = require('karma-webpack-bundle');

module.exports = eslintrc;

eslintrcTests : object

An eslint config object that overrides various rules from the main config for test files.

Example
Create a file in your tests directory called .eslintrc.cjs:

const { eslintrcTests } = require('karma-webpack-bundle');

module.exports = eslintrcTests;

formatBenchmark(benchmark, browser, config) ⇒ string

A plugin for the karma-benchmarkjs-reporter formatBenchmark option. Only current difference with the default formatter is the hz number is passed through toLocaleString to make the number more readable. This is used in karmaBenchConfig.

ParamTypeDescription
benchmarkobjectThe benchmark object.
browserobjectBrowser data.
configobjectThe config object.

karmaBenchConfig(settings) ⇒ function

Returns a config function that can be used with karma-benchmark. Sets up karma-benchmark to run in Chrome headless with karma-benchmarkjs-reporter (with the local formatBenchmark formatter), and webpack in production mode. Looks for files in a bench directory that match **\/*.bench.js.

ParamTypeDescription
settingsobjectOverrides any of the provided settings.

Example
create a file in the root of your project called karma.bench.conf.js:

const {karmaBenchConfig} = require('karma-webpack-bundle');

module.exports = karmaBenchConfig();

and add a script to package.json:

    "bench": "karma start karma.bench.conf.js"

then run it:

npm run bench

karmaConfig(testRunnerConfig, settings) ⇒ function

Returns a config function that can be used with karma. Sets up karma to run in Chrome headless and Firefox headless with mocha and karma-mocha-reporter.

If --single-run is provided then webpack runs in production mode, otherwise it runs in dev mode.

If running on Travis CI then karma-coverage and karma-coveralls are added to reporters

By default it Looks for test files in a tests directory that match .test.js. For source files it looks for index.js, and .js files in a src directory or lib directory.

ParamTypeDescription
testRunnerConfigArrayA valid config for test-runner-config.
settingsobjectOverrides any of the provided settings.

Example
Create a file in the root of your project called karma.conf.js:

const { karmaConfig } = require('karma-webpack-bundle');

module.exports = karmaConfig();

and add a script or two to package.json:

    "test": "karma start --single-run",
    "test-watch": "karma start",

then run it:

npm test

wallabyConfig(testRunnerConfig, settings) ⇒ function

Returns a config function that can be used with wallaby. Sets the test framework to mocha, runs in Chrome headless, and sets up webpack similar to the karma config.

By default it Looks for test files in a tests directory that match .test.js. For source files it looks for index.js, and .js files in a src directory or lib directory.

ParamTypeDescription
testRunnerConfigArrayA valid config for test-runner-config.
settingsobjectOverrides any of the provided settings.

Example
create a file in the root of your project called wallaby.conf.js:

const { wallabyConfig } = require('karma-webpack-bundle');

module.exports = wallabyConfig();