Skip to content

Errors don't show when using experimental mocking #21

@chrisdothtml

Description

@chrisdothtml

Looks like for some reason this package swallows errors if the experimental mocking is enabled.

I was setting up a basic test to play around with mocking and made a failing test like this:

import assert from 'node:assert';
import test from 'node:test';

test('greet', async (t) => {
  t.mock.module('../some-module.js', {
    namedExports: {
      greet() {
        return `Goodbye, World!`;
      },
    },
  });

  const { greet } = await import('../some-module.js');

  assert.equal(greet(), 'Hello, World!');
});

and when I ran it via:

node --test --experimental-test-module-mocks --test-reporter=@voxpelli/node-test-pretty-reporter ./greet.test.js

the only thing it emitted was this:

ℹ tests 1
ℹ suites 0
ℹ pass 0
ℹ fail 1
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 214.166458

Running with the default node test reporter shows errors correctly, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions