mocha-parallel-tests
mocha-parallel-tests copied to clipboard
TypeError: "x" is not a constructor
Hi, I am experiencing the following error running one of my test suites.
Command: mocha-parallel-tests --opts ./mocha.opts --max-parallel 5 --slow 50
mocha.opts content as follows --reporter mocha-jenkins-reporter --timeout 300000 --require ts-node/register --require tsconfig-paths/register tests/**/*.ts
error: testfile.ts:15 const httpService: ApiService = new ApiService();
class instance : const httpService: ApiService = new ApiService();
class constructor:
constructor( jwtType: JWTType = 'defaultValue' ) {
this._environmentUrl = `${environmentUrl}`;
this.jwtType = jwtType ;
}
Any help would be much appreciated Thanks
Thanks for posting this issue @fasatrix. Still, it's not enough information to reproduce this issue.
- Does it happen when you run tests in only one file testfile.ts? Can you publish it here?
- Could you please show the whole stack trace with
--full-trace? - Does this error occur when you run your tests with
mocha? - Can you publish any small repo where this error is reproducible?
HI , thanks for the quick response.
- I am not sure what answer to this question, parallel test will run the entire suite which is comprised of several files and folders. What I have noticed is that if I reduce the number of threads to 1 then the tests start being executed and only when the runner gets to the one that instantiate the class breaks.
- the output of this command (mocha-parallel-tests --opts ./mocha.opts --max-parallel 5 --slow 50 --full-trace) does produce the same results as if --full-trace was not included, I added more info from the error below
- No it does not this is the reason of why I believe there might be a bug with the package
- Sorry I am unable to share/publish the repo unfortunately as it is sensitive
TypeError: api_services_1.ApiService is not a constructor
at Object.
This will be hard to reproduce since we have only these two things as an input:
mocha.opts file
--reporter mocha-jenkins-reporter
--timeout 300000
--require ts-node/register
--require tsconfig-paths/register
tests/**/*.ts
And some test TS file with this:
type JWTType = 'defaultValue';
class ApiService {
_environmentUrl: string;
jwtType: JWTType;
constructor( jwtType: JWTType = 'defaultValue' ) {
this._environmentUrl = `${environmentUrl}`;
this.jwtType = jwtType ;
}
}
describe('suite', () => {
it('case', () => {
const obj = new ApiService();
});
});
If it works, I will not have any other ideas other than close this issue.
No worries lets close it
Nah, let's keep it open so that someone can take a look at it.