Skip to content

Use the Mocha example fails with .ts tests #64

@contd

Description

@contd

The tests run with Mocha from the command line but when I try to integrate the agent-js-mocha using the API approach, it runs and reports an empty report to my ReportPortal endpoint because there are no tests. I then add the same file pattern I use from the command line and I get errors. Here is my test.js:

`const Mocha = require('mocha');
require('@reportportal/agent-js-mocha');

const mochaMain = new Mocha({
require: 'ts-node/register',
reporter: '@reportportal/agent-js-mocha',
reporterOptions: {
endpoint: 'https://reportportal.xxxx.com/api/v1',
token: 'xxxxxxxxx',
launch: 'HelmsdeepCC-MochaTesting',
project: 'default_personal',
description: 'HelmsdeepCC-MochaTesting'
},
timeout: 250000,
});

// run tests
try {
mochaMain.files = ['tests/*.spec.ts'];
// exit with non-zero exit code, other wise fails will not fail mocha run
mochaMain.run(failures => process.on('exit', () => process.exit(failures)));
} catch (err) {
console.error(Test suite doesn't exists or set. Error: ${err});
}`

And here is the error I am getting:

Test suite doesn't exists or set. Error: Error: Cannot find module '/xxxxx/tests/*.spec.ts'

These tests run from the command line with mocha and all the other options except ReportPortal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions