🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

testcafe-reporter-custom

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testcafe-reporter-custom

TestCafe reporter that allows you to provide your own logic

1.2.1
latest
Source
npm
Version published
Maintainers
1
Created
Source

testcafe-reporter-custom

This is the custom reporter plugin for TestCafe.

Install

npm install testcafe-reporter-custom

Usage

When you run tests from the command line, specify the reporter name by using the --reporter option:

testcafe chrome 'path/to/test/file.js' --reporter custom

When you use API, pass the reporter name to the reporter() method:

testCafe
    .createRunner()
    .src('path/to/test/file.js')
    .browsers('chrome')
    .reporter('custom') // <-
    .run();

After that you can define your custom logic in reporter/index.js file.
It can be defined as an object or factory function.

For example:

module.exports = function () {
    return {
        async reportTaskStart(/* startTime, userAgents, testCount */) {
            throw new Error('Not implemented');
        },

        async reportFixtureStart(/* name, path, meta */) {
            throw new Error('Not implemented');
        },

        async reportTestStart(/* name, meta */) {
            // NOTE: This method is optional.
        },

        async reportTestDone(/* name, testRunInfo, meta */) {
            throw new Error('Not implemented');
        },

        async reportTaskDone(/* endTime, passed, warnings, result */) {
            throw new Error('Not implemented');
        }
    };
}

API is completely the same as for regular reporter.

Configuration

Reporter can be configured using reporter.config.js file, which should be placed in a project root folder.

module.exports = {
    path: 'reporter/main.js'
};

Possible options are presented in the table below.

OptionDefault ValueDescription
path'reporter/index.js'Path to your reporter.
moduleType'commonjs'Whether your reporter uses CommonJS or ES Modules. Possible values are commonjs and module.
tsNodePath'node_modules/ts-node'Path to your ts-node installation (only used for *.ts files).
tsOptionsundefinedts-node options (only used for *.ts files).

TypeScript Usage

In order to use TypeScript with this reporter, at least ts-node and typescript packages should be installed.

npm install --save-dev ts-node typescript

After that you need to create reporter.config.ts file and specify path to your reporter.

module.exports = {
    path: 'reporter/index.ts'
};

As testcafe-reporter-custom use ts-node in order to execute TypeScript files, all it's rules are applied.

If you want to provide additional ts-node options, you can use tsOptions in the reporter configuration file.
For example, you can specify custom tsconfig file using the following configuration:

module.exports = {
    path: 'reporter/index.ts',
    tsOptions: {
        project: 'tsconfig.reporter.json'
    }
};

Usage Examples

There is a couple of usage examples available in this repository:

Keywords

testcafe

FAQs

Package last updated on 31 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts