Files
formipay/node_modules/eslint-plugin-jest/docs/rules/prefer-expect-resolves.md
dwindown e8fbfb14c1 fix: prevent asset conflicts between React and Grid.js versions
Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 17:02:14 +07:00

1.6 KiB

Prefer await expect(...).resolves over expect(await ...) syntax (prefer-expect-resolves)

🔧 This rule is automatically fixable by the --fix CLI option.

When working with promises, there are two primary ways you can test the resolved value:

  1. use the resolve modifier on expect (await expect(...).resolves.<matcher> style)
  2. await the promise and assert against its result (expect(await ...).<matcher> style)

While the second style is arguably less dependent on jest, if the promise rejects it will be treated as a general error, resulting in less predictable behaviour and output from jest.

Additionally, favoring the first style ensures consistency with its rejects counterpart, as there is no way of "awaiting" a rejection.

Rule details

This rule triggers a warning if an await is done within an expect, and recommends using resolves instead.

Examples of incorrect code for this rule

it('passes', async () => {
  expect(await someValue()).toBe(true);
});

it('is true', async () => {
  const myPromise = Promise.resolve(true);

  expect(await myPromise).toBe(true);
});

Examples of correct code for this rule

it('passes', async () => {
  await expect(someValue()).resolves.toBe(true);
});

it('is true', async () => {
  const myPromise = Promise.resolve(true);

  await expect(myPromise).resolves.toBe(true);
});

it('errors', async () => {
  await expect(Promise.reject(new Error('oh noes!'))).rejects.toThrowError(
    'oh noes!',
  );
});