Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the Mocha example fails with .ts tests #70

Closed
contd opened this issue Aug 9, 2021 · 1 comment
Closed

Use the Mocha example fails with .ts tests #70

contd opened this issue Aug 9, 2021 · 1 comment

Comments

@contd
Copy link

contd commented Aug 9, 2021

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.

@chivekrodis chivekrodis transferred this issue from reportportal/examples-js Nov 16, 2021
@AmsterGet
Copy link
Member

Closed as a duplicate of #64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants