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

Error when dealing with non-error test failures in Jest #1232

Closed
Robinfr opened this issue Jan 27, 2025 · 0 comments · Fixed by #1238
Closed

Error when dealing with non-error test failures in Jest #1232

Robinfr opened this issue Jan 27, 2025 · 0 comments · Fixed by #1238
Labels
theme:jest Jest related issue type:bug Something isn't working

Comments

@Robinfr
Copy link

Robinfr commented Jan 27, 2025

Describe the bug
When a test returns a non-error test failure, Allure will return an error when trying to extract the message and trace. For example, when a timeout is reached in Jest. This also means the test will not be marked as failure but be completely ignored in the final result.

To Reproduce
Install both Jest and Allure Jest and run the following test:

function add(a, b) {
    return a + b;
}

describe("test/index", function () {
    it("should add two numbers", async () => {
        await new Promise(resolve => setTimeout(resolve, 10000));
        expect(add(1, 2)).toEqual(3);
    }, 5000);
});

This will throw the following error:

TypeError: Cannot use 'in' operator to search for 'actual' in Exceeded timeout of 5000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout.

      at getMessageAndTraceFromError (node_modules/allure-js-commons/src/sdk/utils.ts:49:26)
      at NodeEnvironment._statusAndDetails (node_modules/allure-jest/src/environmentFactory.ts:372:50)
      at NodeEnvironment.call (node_modules/allure-jest/src/environmentFactory.ts:296:57)
      at NodeEnvironment.call [as handleTestEvent] (node_modules/allure-jest/src/environmentFactory.ts:106:31)

Expected behavior
It should not throw an error and simply return the message as the cause, correctly marking it as failed with the proper cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:jest Jest related issue type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants