Skip to content
Permalink
Browse files
fix(docs): documented Cucumber configuration better
  • Loading branch information
jan-molak committed Jun 10, 2020
1 parent c7cfd0d commit 04ed39a9d0902da9ab94c938e83a7e021377e678
Showing 5 changed files with 77 additions and 26 deletions.
@@ -28,3 +28,5 @@ To see an example integration, have a look at [Serenity/JS Github](https://githu
## Configuration

Serenity/JS can be configured using a [`SerenityConfig`](/modules/core/class/src/SerenityConfig.ts~SerenityConfig.html) object specified in the [Protractor configuration file](/modules/protractor).

Learn more from the `@serenity-js/protractor` module [readme](/modules/protractor/).
@@ -7,38 +7,72 @@ export interface CucumberConfig {
* Step definitions and support files can be written in languages that transpile to JavaScript.
* To do set the `compiler` option to <file_extension>:<module_name>
*
* For Cucumber 4.x and above use the `require` option instead.
* For Cucumber 4.x and above use the {@link CucumberConfig#require} option instead.
*
* @example <caption>Enable TypeScript support in Cucumber 1.x - 3.x</caption>
* compiler: 'ts:ts-node/register'
*
* @link https://github.com/cucumber/cucumber-js/blob/3.x/docs/cli.md#transpilers
* @type {string}
* @see https://github.com/cucumber/cucumber-js/blob/3.x/docs/cli.md#transpilers
* @version 1.x - 3.x
*/
compiler?: string;

/**
* @link https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#formats
* @desc
* Specify additional output formats, optionally supply PATH to redirect formatter output
*
* @type {string}
* @see https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#formats
*/
format?: string;

/**
* @link https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#format-options
* @desc
* Provide options for formatters
*
* @example <caption>Cucumber 1.x</caption>
* formatOptions: JSON.stringify({ option: 'value' })
*
* @type {string}
* @see https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#format-options
*/
formatOptions?: string;

/**
* @link https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#running-specific-features
* @desc
* Only execute the scenarios with name matching the expression.
*
* @type {string}
* @see https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#running-specific-features
*/
name?: string[];

/**
* @link https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#profiles
* @desc
* In order to store and reuse commonly used CLI options,
* you can add a `cucumber.js` file to your project root directory.
* The file should export an object where the key is the profile name
* and the value is a string of CLI options.
*
* The profile can be applied with -p <NAME> or --profile <NAME>.
* This will prepend the profile's CLI options to the ones provided by the command line.
* Multiple profiles can be specified at a time.
*
* If no profile is specified and a profile named default exists,
* it will be applied.
*
* @type {string}
* @see https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#profiles
*/
profile?: string[];

/**
* @link https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#requiring-support-files
* @desc
* Require files before executing features
*
* @type {string}
* @see https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#requiring-support-files
*/
require?: string[];

@@ -53,21 +87,30 @@ export interface CucumberConfig {
* @example <caption>Cucumber >= 2.x</caption>
* tag: '@smoketest and not @wip'
*
* @link https://github.com/cucumber/cucumber-js/blob/1.x/docs/cli.md#tags
* @link https://github.com/cucumber/cucumber-js/blob/2.x/docs/cli.md#tags
*
* @type {string[]|string}
* @see https://github.com/cucumber/cucumber-js/blob/1.x/docs/cli.md#tags
* @see https://github.com/cucumber/cucumber-js/blob/2.x/docs/cli.md#tags
*/
tags?: string[] | string;

/**
* @link https://github.com/angular/protractor/blob/e5a5d59fcabe15860b30944e714bbd8e81ceaeae/docs/frameworks.md#using-cucumber
* @desc
* Fail if there are any undefined or pending steps
*
* @type {boolean}
* @see https://github.com/angular/protractor/blob/e5a5d59fcabe15860b30944e714bbd8e81ceaeae/docs/frameworks.md#using-cucumber
*/
strict?: boolean;

'no-colors'?: boolean;

/**
* @link https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#world-parameters
* @desc
* Provide parameters that will be passed to the world constructor
*
* @example <caption>Cucumber 1.x</caption>
* worldParameters: JSON.stringify({ isDev: process.env.NODE_ENV !== 'production' })
*
* @type {string}
* @see https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#world-parameters
*/
worldParameters?: string;
}
@@ -1,8 +1 @@
export type Constructor<T> = new (...args: any[]) => T;

/**
* @private
*/
export interface Constructable<T> {
constructor: Function; // tslint:disable-line:ban-types
}
@@ -1,15 +1,15 @@
import { Constructable, Constructor } from '../constructables';
import { Constructor } from '../constructables';
import { ItemNotFoundError } from './errors';

/**
* @private
*/
export class FeatureFileMap {

constructor(private readonly map: { [line: number]: Constructable<any> } = {}) {
constructor(private readonly map: { [line: number]: object } = {}) {
}

set<T>(item: Constructable<T>) {
set(item: object) {
return ({
onLine: (line: number): FeatureFileMap => {
this.map[line] = item;
@@ -36,11 +36,24 @@ exports.config = {
]
},
// ... other Protractor-specific configuration
// configure Cucumber runner
cucumberOpts: {
// see the Cucumber configuration options below
},
// configure Jasmine runner
jasmineNodeOpts: {
// see the Jasmine configuration options below
},
// ... other Protractor-specific configuration
};
```

Learn more about [Protractor configuration file](https://github.com/angular/protractor/blob/master/lib/config.ts).
Learn more about:
- [Cucumber configuration options](https://serenity-js.org/modules/cucumber/class/src/cli/CucumberConfig.ts~CucumberConfig.html)
- [Jasmine configuration options](https://serenity-js.org/modules/jasmine/class/src/adapter/JasmineConfig.ts~JasmineConfig.html)
- [Protractor configuration file](https://github.com/angular/protractor/blob/master/lib/config.ts).

### Interacting with websites and web apps

0 comments on commit 04ed39a

Please sign in to comment.