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

Invert failure output #38

Open
darcyrush opened this issue Feb 17, 2025 · 0 comments
Open

Invert failure output #38

darcyrush opened this issue Feb 17, 2025 · 0 comments

Comments

@darcyrush
Copy link

darcyrush commented Feb 17, 2025

I'm not sure this is the same as issue #3, but currently the parser outputs the assertion message, ID and error details of a failed test when it fails, and outputs the assertion message and ID in the summary.

IMHO I believe a better approach would be to 'invert' the failure output to output the assertion message and ID when it fails, and output the assertion message, ID and details of the failed test in the summary.

This would match the modern node:test library in terms of the UI and DX. It makes both large and small test suites much easier to use since you only need to scroll a few lines to see why and where an error happened as opposed to potentially hundreds or even thousands.

In our case, we have a very large test suite and the summary output is useless because we have many duplicated assertion messages meaning we cannot uniquely search them, and since the errors happen early in the test suite, the terminal history is exhausted so we cannot scroll to see why tests failed.

Current;

example failed test
    ✓ should be deeply equivalent
    ✗ [30] should be deeply equivalent
        Actual:   "{ method: 'GET', url: 'hostUrl/example' }"
        Expected: {"method":"POST","url":"hostUrl/example" }
        At: <anonymous> (/test/unit/example.test.ts:1:1)

Failed tests: There was 1 failure

    ✗ [30] should be deeply equivalent

Proposed;

example failed test
    ✓ should be deeply equivalent
    ✗ [30] should be deeply equivalent

Failed tests: There was 1 failure

✗ [30] should be deeply equivalent
        Actual:   "{ method: 'GET', url: 'hostUrl/example' }"
        Expected: {"method":"POST","url":"hostUrl/example" }
        At: <anonymous> (/test/unit/example.test.ts:1:1)

As a workaround we are using --bail, but this is not ideal.

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

No branches or pull requests

1 participant