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

buster-testbed-extension

0.1.3 • Public • Published

buster-testbed-extension

Build status

This extension for Buster.JS uses the preConfigure extension hook to dynamically add configuration groups at runtime.

You need version >=0.6.3 of buster-cli to use the extension.

Installation

npm install buster-testbed-extension

Usage

You need at least one configuration group in your Buster.JS configuration file:

var config = module.exports;
 
config["base"] = {
    environment: "browser",
    extensions: [require("buster-testbed-extension")],
    "buster-testbed-extension": {
        testbeds: ["testbed/**/*.html"],
        tests: ...
    }
};

The given configuration group loads and configures the extension with the following parameters:

testbeds

Array of glob patterns to select the testbeds, for which configuration groups have to be added.

tests

This parameter contains the information needed to create the glob patterns for selecting the corresponding JavaScript test files for the testbeds. Depending on the mode, which should be used, different kinds of informations has to be provided.

Simple mode:

Directory from which to start with the selection of the JavaScript test files.

RegExp mode:

Information about how to modify the testbed path to get the path for the JavaScript test files.

strict: false

By default the extension adds a configuration group for every found testbed. If Buster.JS can't find any javascript test file for a testbed afterwards, it will report that as an error. Specifying the option strict: false instructs the extension, only to add a configuration group for a testbed, if at least one corresponding javascript test file exists for it.

Simple mode

The glob pattern for selecting the JavaScript test files is build by:

  • Take the path of the testbed including the file name.
  • Replace the first part of the path with the path specified by the tests parameter of the extension. The number of subdirectories which are replaced, complies to the number of subdirectories of the path in the tests parameter.
  • Change the extension of the file to js and add an additional asterisk, to allow to have more than one JavaScript test file per testbed.

Example

Directory structure:

├── test/
│   ├── gen/
│   │   ├── timeStructure.html
│   │   ├── time/
│   │       ├── structure/
│   │           ├── timeStructure.html
│   ├── spec/
│       ├── timeStructure-test.js
│       ├── timeStructure-test2.js
│       ├── time/
│           ├── structure/
│               ├── timeStructure-test.js
│               ├── timeStructure-test2.js
├── buster.js

buster.js:

var config = module.exports;
 
config["base"] = {
    environment: "browser",
    extensions: [require("buster-testbed-extension")],
    "buster-testbed-extension": {
        testbeds: ["test/gen/**/*.html"],
        tests: ["test/spec"]
    }
};

Resulting configuration at runtime:

var config = module.exports;
 
config["base"] = {
    environment: "browser",
    extensions: [require("buster-testbed-extension")],
    "buster-testbed-extension": {
        testbeds: ["test/gen/**/*.html"],
        tests: ["test/spec"]
    }
};
 
config["test/gen/timeStructure.html"] = {
    extends: "base",
    testbed: "test/gen/timeStructure.html",
    tests: ["test/spec/timeStructure*.js"]
};
 
config["test/gen/time/structure/timeStructure.html"] = {
    extends: "base",
    testbed: "test/gen/time/structure/timeStructure.html",
    tests: ["test/spec/time/structure/timeStructure*.js"]
};

RegExp mode

In this mode the tests parameter of the extension is an array of length 2, with first element of type RegExp and second element a string literal.

These elements are used as params for the string.replace method, which is used to transform the path of a testbed to get the path to the corresponding JavaScript test files.

Example

Directory structure:

├── test/
│   ├── testbeds/
│   │   ├── gen/
│   │       ├── timeStructure.html
│   │       ├── time/
│   │           ├── structure/
│   │               ├── timeStructure.html
│   ├── spec/
│       ├── timeStructure-test.js
│       ├── timeStructure-test2.js
│       ├── time/
│           ├── structure/
│               ├── timeStructure-test.js
│               ├── timeStructure-test2.js
├── buster.js

buster.js:

var config = module.exports;
 
config["base"] = {
    environment: "browser",
    extensions: [require("buster-testbed-extension")],
    "buster-testbed-extension": {
        testbeds: ["test/testbeds/gen/**/*.html"],
        tests: [/^test\/testbeds\/gen/, "test/spec"]
    }
};

Resulting configuration at runtime:

var config = module.exports;
 
config["base"] = {
    environment: "browser",
    extensions: [require("buster-testbed-extension")],
    "buster-testbed-extension": {
        testbeds: ["test/testbeds/gen/**/*.html"],
        tests: [/^test\/testbeds\/gen/, "test/spec"]
    }
};
 
config["test/testbeds/gen/timeStructure.html"] = {
    extends: "base",
    testbed: "test/testbeds/gen/timeStructure.html",
    tests: ["test/spec/timeStructure*.js"]
};
 
config["test/testbeds/gen/time/structure/timeStructure.html"] = {
    extends: "base",
    testbed: "test/testbeds/gen/time/structure/timeStructure.html",
    tests: ["test/spec/time/structure/timeStructure*.js"]
};

Changelog

0.1.3 (14.07.2015)

0.1.2 (25.09.2014)

0.1.1 (24.09.2014)

Keywords

none

install

npm i buster-testbed-extension

Downloadsweekly downloads

5

version

0.1.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability