Skip to content

Failing tests are passing #1128

@samjrdn

Description

@samjrdn

Issue summary

There are a number of tests, specifically in ComboBox.test.tsx and perhaps elsewhere, that are passing because the assertions are not called.

The affected code has this pattern:

async () => {
  comboBox.find(TextField).simulate('click');
  listenerMap.keyup({keyCode: Key.DownArrow});
  await expect(comboBox.state('selectedIndex')).toBe(0);
};

which declares a function that never gets executed.

Expected behavior

The code wrapped inside the async arrow functions should be executed.

Actual behavior

The code inside the async arrow functions is never executed because the async arrow function is declared but never called.

Steps to reproduce the problem

  1. Add a throw Error() inside the async arrow function
  2. Run the test and observe that it still passes

Possible solution

Modify tests with the following pattern:

it('test description', () => {
  ...
  async () => {
    await ...
  };
});

to be

it('test description', async () => {
  ...
  await ...
});

It is also a good idea to verify the number of assertions the test will call using expect.assertions(number).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions