nightwatch: Regression: Custom reporter not working for multiple test files execution

This seems broken since v0.9.0 release. Custom reporter works with just one test file execution but doesn’t work when executing a set of test files. This is for both approaches, --reporter and reporter method in external globals file.

I tried with v0.8.18 and it works fine for any test executions.

Its surprising that no one even reported this issue (does that mean nobody is using this feature? )

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 21 (1 by maintainers)

Commits related to this issue

Most upvoted comments

@lreading we have a workaround in place that uses the global afterEach hook. The client parameter contains a currentTest property with which we update a json.

This is a rough example (might need some readaption to work correctly).

const filePath = 'some/path/to.json';

afterEach: (client, done) => {
    const { currentTest } = client;
    let results;

    try {
        results = require(filePath);
    } catch (e) {
        results = {};
    }

    const data = {
        name: currentTest.module,
        success: currentTest.results.errors === 0 && currentTest.results.failed === 0,
        errors: Object.entries(currentTest.results.testcases).reduce((errors, [testcaseName, testcase]) => {
            if (testcase.errors !== 0 || testcase.failed !== 0) {
                errors.push({
                    testcase: testcaseName,
                    assertions: testcase.assertions
                });
            }

            return errors;
        }, [])
    };

    results[data.name] = data;

    try {
        fs.writeFileSync(filePath, JSON.stringify(results), "utf8");
    } catch (e) {
        console.log(`An error occured while saving ${filePath}:`);
        console.log(e);
    }

    done()
};

+1. Able to reproduce in 0.9.19