Skip to content

valid-expect-in-promise doesn't work with Promise.all #219

@realityking

Description

@realityking

I have a test case that relies on multiple promises being tested with Promise.all:

test('Resource loader: client usage', function () {
  expect.assertions(2);

  const quxLoader = ResourceLoader.create(['qux']);
  let promiseResolve;
  fetchResult = new Promise(resolve => promiseResolve = resolve);

  const promise1 = quxLoader.load();
  promise1.then(([x]) => expect(x.test).toBeTruthy());
  const promise2 = quxLoader.load();
  promise2.then(([x])  => expect(x.test).toBeTruthy());
  promiseResolve({test: true});

  return Promise.all([promise1, promise2]);
});

This causes the following eslint errors:

  68:3  error  Promise should be returned to test its fulfillment or rejection  jest/valid-expect-in-promise
  70:3  error  Promise should be returned to test its fulfillment or rejection  jest/valid-expect-in-promise

It'd be great if the rule would recognize Promise.all and considered it valid.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions