-1

I have errors that I make in code:

export class UnprocessableException extends Error {
    constructor(message: string) {
        super(responseStatus.UNPROCESSABLE, message);
    }
}

I then test them in jest tests like:

try {
    ....
} catch (e) {
    expect(e).toBeInstanceOf(UnprocessableException);
}

This passes/works locally, but on Bitbucket the tests fail with the same commands. The tests all say:

Expected: UnprocessableException 

Received: Error

Any idea why jest and bitbucket types don't seem to like each other?

meh93
  • 311
  • 4
  • 13
  • Note that your text still passes if the code in the try _doesn't_ throw an error. Use [`toThrow`](https://jestjs.io/docs/expect#tothrowerror) (with [`rejects`](https://jestjs.io/docs/expect#rejects) if you're testing a promise). – jonrsharpe Mar 04 '23 at 09:03

1 Answers1

0

Of course I get it working right after I post the question. So changing

- npm run build
- npm run test

to

- npm test
- npm run build

Fixed it. The build command just builds webpack, so I don't think it was the order. But not having "run" seems to fix the issue. Not sure how as npm run test also works on my local machine.

meh93
  • 311
  • 4
  • 13