or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

browser-utilities.mdconfiguration.mdindex.mdinstrumentation.mdpattern-matching.mdreporting.mdtest-integration.md
tile.json

configuration.mddocs/

Configuration

Blanket.js configuration system for controlling coverage behavior, file filtering, and output options.

Capabilities

Options Method

Central configuration method for getting and setting all Blanket.js options.

/**
 * Get or set configuration options
 * @param key - Option key (string) or options object
 * @param value - Option value (when key is string)
 * @returns Option value (when used as getter), undefined (when used as setter)
 */
function options(key, value);

Usage Examples:

// Set single option
blanket.options("filter", "src/");

// Set multiple options
blanket.options({
  filter: "src/",
  antifilter: "test/",
  debug: true
});

// Get option value
const currentFilter = blanket.options("filter");

Utility Methods

/**
 * Get the coverage variable name
 * @returns Coverage variable name ("window._$blanket" in browser, "_$jscoverage" in Node.js, or custom)
 */
function getCovVar();

/**
 * Extend blanket object with additional properties/methods
 * @param obj - Object with properties to add to blanket
 */
function extend(obj);

/**
 * Return control of the blanket variable to previous owner
 * @returns Previous blanket instance or current instance
 */
function noConflict();

Configuration Options

File Filtering Options

filter - Pattern to match files for instrumentation

  • Type: string | string[] | RegExp | Function
  • Default: "src"
  • Examples:
    // String pattern (substring match)
    blanket.options("filter", "src/");
    
    // Array of patterns
    blanket.options("filter", ["src/", "lib/"]);
    
    // Regular expression
    blanket.options("filter", /^src\//);
    
    // Function
    blanket.options("filter", function(filename) {
      return filename.indexOf("src/") >= 0;
    });

antifilter - Pattern to exclude files from instrumentation

  • Type: string | string[] | RegExp | Function
  • Default: undefined
  • Description: Files matching this pattern will never be instrumented, even if they match the filter

Reporter Options

reporter - Coverage report output handler

  • Type: string | Function
  • Default: Built-in HTML reporter (browser) or console reporter (Node.js)
  • Examples:
    // Path to custom reporter
    blanket.options("reporter", "./custom-reporter.js");
    
    // Custom reporter function
    blanket.options("reporter", function(coverageData) {
      console.log("Coverage:", coverageData);
    });

reporter_options - Options passed to reporters

  • Type: object
  • Properties:
    • shortnames (boolean): Use short filenames in reports
    • relativepath (boolean): Use relative paths from current directory
    • basepath (string): Base path to remove from filenames

Test Framework Integration

adapter - Test framework adapter

  • Type: string
  • Examples: "mocha-blanket", "jasmine-blanket", "qunit-blanket"

testReadyCallback - Callback when tests are ready to run

  • Type: Function
  • Description: Called when all files are instrumented and ready for testing

File Loading Options

loader - Custom file loaders for different file types

  • Type: string | string[]
  • Examples:
    // Single loader
    blanket.options("loader", "./node-loaders/coffee-script");
    
    // Multiple loaders
    blanket.options("loader", [
      "./node-loaders/coffee-script",
      "./node-loaders/cjsx"
    ]);

timeout - File loading timeout in milliseconds

  • Type: number
  • Default: 180

Behavioral Flags

ignoreScriptError - Continue on script instrumentation errors

  • Type: boolean
  • Default: false
  • Description: When true, continues execution if a file fails to instrument

autoStart - Automatically start test runner

  • Type: boolean
  • Default: false

branchTracking - Enable branch coverage tracking

  • Type: boolean
  • Default: false
  • Description: Tracks which branches of conditional statements are executed

debug - Enable debug logging

  • Type: boolean
  • Default: false
  • Description: Outputs detailed logging to console during instrumentation

engineOnly - Instrumentation engine only mode

  • Type: boolean
  • Default: false
  • Description: Only provides instrumentation engine without require.extensions integration

commonJS - CommonJS module support

  • Type: boolean
  • Default: false

Browser-Specific Options

existingRequireJS - Use existing RequireJS instance

  • Type: boolean
  • Default: false

ignoreCors - Ignore CORS errors when loading files

  • Type: boolean
  • Default: false

sourceURL - Add sourceURL comments to instrumented code

  • Type: boolean
  • Default: false

instrumentCache - Cache instrumented files in sessionStorage

  • Type: boolean
  • Default: false

Advanced Options

customVariable - Custom coverage variable name

  • Type: string
  • Default: undefined
  • Description: Override default coverage variable (_$blanket or _$jscoverage)

modulePattern - Pattern for module grouping in reports

  • Type: RegExp
  • Description: Groups related files together in coverage reports

ecmaVersion - ECMAScript version for parsing

  • Type: number
  • Default: 5
  • Description: ECMAScript version passed to the Esprima parser

Package.json Configuration

Blanket.js can also be configured via package.json:

{
  "config": {
    "blanket": {
      "pattern": "src/",
      "data-cover-flags": {
        "debug": false,
        "branchTracking": true
      },
      "data-cover-reporter-options": {
        "shortnames": true
      }
    }
  }
}

Configuration keys in package.json:

  • pattern or data-cover-onlyfilter option
  • data-cover-neverantifilter option
  • loader or data-cover-loaderloader option
  • data-cover-timeouttimeout option
  • data-cover-customVariablecustomVariable option
  • data-cover-ecmaVersionecmaVersion option
  • data-cover-flags → various boolean flags
  • data-cover-reporter-optionsreporter_options object