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

test_runner: chai.expect() error properties are missing in reporter #56017

Open
f3oall opened this issue Nov 27, 2024 · 1 comment
Open

test_runner: chai.expect() error properties are missing in reporter #56017

f3oall opened this issue Nov 27, 2024 · 1 comment

Comments

@f3oall
Copy link

f3oall commented Nov 27, 2024

Version

v22.11.0

Platform

Linux F3OAllGAMELAP 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

test_runner

What steps will reproduce the bug?

import {describe, it} from 'node:test'
import {expect} from 'chai'

describe('Group', () => {
    it('should show diff if fails', () => {
        try {
            expect({number: {type: Number}}).to.deep.equal({number: {type: Number, required: true}}) 
        } catch (e) {
            console.log('Actual Error', e) // AssertionError from chai has `actual`, `expected` and `showDiff` properties
            throw e // but in test reporter, these properties are missing
        }
    })
    it('shows diff if fails', () => {
        expect({number: {type: 1}}).to.deep.equal({number: {type: 2, required: true}}) // works fine, when no function type is present
    })
})

Run this code with node --test, seems like running it with just node fixes the issue.

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior? Why is that the expected behavior?

AssertionError properties like (actual, expected) are preserved.

What do you see instead?

AssertionError properties are missing, if some of them have functions inside.

Additional information

Repo for reproduction: https://github.com/f3oall/node-test-runner-issue

@cjihrig
Copy link
Contributor

cjihrig commented Nov 27, 2024

This has nothing to do with chai. The reason you aren't seeing those function values is because a function cannot be sent between processes (which is what happens with --test). If you run with --test --experimental-test-isolation=none, which does not spawn any child processes, you'll see the functions included.

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

2 participants