Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

@bb-cli/bb-test

2.10.3 • Public • Published

NAME

bb-test - Command line tool for source code analysis (lint), and unit testing

SYNOPSIS

bb-test [--help] [-v|--version]
bb-test lint [--help] [-f|--format <format>] [-o|--output <file>]
    [-c|--eslint-config <config file>] [-x --exclude <node glob>] [src]
bb-test unit [--help] [--prebuilt <paths>] [--load-prebuilt <names>]
    [-x --exclude <node glob>] [-b|--build-plugins <file|node_modules>] [-t|--test-plugins <plugin-list>]
    [--karma-plugins <plugin-list>] [--disable-karma-plugins] [-f|--format <format>]
    [-B|--browsers <browsers>] [--coverage <reporters>] [-w|--watch] [sources...]

OPTIONS

Option Description
-v, --version output the version number
--help Output usage information

COMMANDS

NAME

bb-test lint - Run eslint and report javascript lint errors

SYNOPSIS

bb-test lint [--help] [-f|--format <format>] [-o|--output <file>]
    [-c|--eslint-config <config file>] [-x --exclude <node glob>] [src]

DESCRIPTION

By default bb-test lint uses the @backbase/eslint-config-backbase package for the linting rules. These rules are strongly based on the airbnb es6 rules.

If you specify a custom eslint config file, it's recommended to extend from @backbase/eslint-config-backbase rules.

OPTIONS

Option Description
-f, --format <format> Use a specific output format
-o, --output <file> Specify output file to write report to
-c, --eslint-config <config file> Custom eslint configuration file
-x --exclude <node glob> Comma separated paths/globs to ignore. Make sure to wrap globs in single quotes to avoid shell expansion
--help Output usage information

EXAMPLES

Lint all javascript files in the current directory:

  $ bb-test lint

Lint all javascript files in a sub directory (single quotes to avoid bash expansion):

  $ bb-test lint 'src/**/*.js'

Lint using a custom config file:

  $ bb-test lint --eslint-config ./eslint.conf.json

Exclude custom glob patterns from linting:

  $ bb-test lint --exclude 'prebuilt/*,assets/*'

NAME

bb-test unit - Run unit tests for CXP items

SYNOPSIS

bb-test unit [--help] [--prebuilt <paths>] [--load-prebuilt <names>]
    [-x --exclude <node glob>] [-b|--build-plugins <file|node_modules>] [-t|--test-plugins <plugin-list>]
    [--karma-plugins <plugin-list>] [--disable-karma-plugins] [-f|--format <format>]
    [-B|--browsers <browsers>] [--coverage <reporters>] [-w|--watch] [sources...]

DESCRIPTION

By default the tests are run in chrome via karma (with webpack) using jasmine.

bb-test unit works in a similar way to bb-package. It will look for all the sources that need to be tested in the current directory (by default). It will also load any prebuilt dependencies in node_modules or target/backbase (by default).

OPTIONS

Option Description
--prebuilt <paths> Comma separated paths to prebuilt items (items that don't require a webpack build). These will be merged with the defaults.
--load-prebuilt <names> Comma separated list of prebuilt items to load in the browser. This is useful if your tests require a global thatis provided by a prebuilt item.
-x --exclude <node glob> Comma separated paths/globs to ignore. Make sure to wrap globs in single quotes to avoid shell expansion. The exclude glob is evaluated relative to each source directory provided. This exclude is applied the same way as bb-package. It shouldn't be used to exclude certain files from testing, but for excluding entire Backbase itemsfrom being found for testing.
-b, --build-plugins <file|node_modules> Comma separated path/node modules to use for the build process
-t, --test-plugins <plugin-list> Comma separated path/node modules to use for unit testing
--karma-plugins <plugin-list> Comma separated names of karma plugins to use for unit testing. If not set, all sibling plugins starting with karma-* will be loaded
--disable-karma-plugins Disable auto-loading of karma-* plugins
-f, --format <format> Comma separated list of output formats. Possible values (without plugins): dots,progress
-B, --browsers <browsers> Browser to launch, by default karma is using a Chrome launcher. In order to launch a browser you must have the karma launcher installed (ignore peer dependency warnings)
--coverage [reporters] Comma separated list of coverage reporters. Possible values: text-summary,html,lcov. Reports will be created in "reports" dir.
-w, --watch Watch files and re-run tests on changes
--help Output usage information

KARMA PLUGINS

All karma plugins are automatically loaded. Karma plugins are npm packages that are installed as peers to bb-test, and begin with 'karma-'.

BROWSERS

Chrome is the default launcher used, but there is support for any karma launcher.

Because karma plugins are loaded automatically, just install the correct plugin for the browser you want to launch. For example, you can install the Firefox Launcher and run bb-test unit with --browsers=Firefox. Make sure to consult the launchers documentation for the correct name of the browser.

It can also accept a comma separated list of browsers.

LOADING PREBUILT FILES

Karma has an option for loading addition files in the browser. bb-test has a similar option where you can load prebuilt files in the page (even if they're not directly imported into one of the items you're testing).

For example, if you have a config-bb-module-loader in your project, which relies on the vendor-bb-systemjs item to already be loaded on the page, you can tell bb-test to always include vendor-bb-systemjs on the page.

TEST PLUGINS

bb-test supports it's own set of test plugins. A bb-test plugin is an npm package that begins with @bb-cli/bb-test-plugin-. To load a plugin just provide that last part of the name to bb-test unit.

For example, there is an angular-mocks plugin that enables you to use ngmock in your tests, and can be loaded via --test-plugins=ngmock https://www.npmjs.com/package/@bb-cli/bb-test-plugin-ngmock

EXAMPLES

Install Firefox launcher and run with firefox:

  $ npm install -g karma-firefox-launcher
  $ bb-test unit --browsers Firefox

Or run with Firefox AND Chrome:

  $ bb-test unit --browsers Firefox,Chrome

Install and run with test plugin @bb-cli/bb-test-plugin-ngmock (which adds support for angular-mocks):

  $ npm install -g @bb-cli/bb-test-plugin-ngmock
  $ bb-test unit --test-plugins ngmock

Run tests with support for compiling sass files:

  $ npm install -g @bb-cli/bb-build-plugin-sass
  $ bb-test unit --build-plugins sass

Create html & lcov coverage in reports/ dir, and print coverage to stdout:

  $ bb-test unit --coverage text-summary,html,lcov

Combining aliases for test-plugins, build-plugins, browsers, and coverage as you might do on a jenkins machine:

  $ bb-test unit -t ngmock -b sass -B PhantomJS --coverage lcov,text-summary

Instead of the current directory, look for CXP source items in src/ with additional prebuilt dependencies in prebuilt/. Note: this will still search for dependencies in node_modules and target/backbase:

  $ bb-test unit src/ --prebuilt prebuilt/

Load vendor-bb-systemjs into the browser so the System global is defined:

  $ bb-test unit --load-prebuilt vendor-bb-systemjs

ENVIRONMENT VARIABLES

bb-test will generate an entry file for the tests. By default a tmp file will be created. Use this to write to a specific file for the test entry. This can be useful for debugging issues with bb-test.

BB_TEST_UNIT_CREATE_ENTRY=entry.js

ENVIRONMENT VARIABLES

Set the amount of log output

LOG_LEVEL=silly|verbose|info|warn|error

Set whether or not to use colors in output

COLOR=false|true

install

npm i @bb-cli/bb-test

Downloadsweekly downloads

174

version

2.10.3

license

SEE LICENSE IN LICENSE

last publish

collaborators

  • avatar
Report a vulnerability