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 #64

Open
contd opened this issue Aug 9, 2021 · 2 comments
Open

Use the Mocha example fails with .ts tests #64

contd opened this issue Aug 9, 2021 · 2 comments

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
Copy link
Contributor

Hello @contd
Could you please specify full path for each necessary spec file? like: ['tests/testA.spec.ts', 'tests/testB.spec.ts'] thats should works

@KrishnaKTechnocredits
Copy link

KrishnaKTechnocredits commented Apr 20, 2022

chivekrodis

what if we want to pass parameter from jenkins,

It should support,
ENV TARGET=DEV npm run report-portal:api-test -- --grep "Test Automation1"
"Test Automation1" will be passed at run time.

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

No branches or pull requests

3 participants