# valid-expect-with-promise

Rule `jest/valid-expect-with-promise`. Require that `resolve` and `reject` modifiers are present (and only) for promise-like types

- Source: jest
- Technologies: Testing
- Kind: style
- Needs type information: yes
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1976 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `jest/valid-expect-with-promise` | no | no | package `eslint-plugin-jest` | [docs](https://github.com/jest-community/eslint-plugin-jest/blob/v29.17.2/docs/rules/valid-expect-with-promise.md) |

## Code examples

### Incorrect: the rule reports this

```ts
expect('hello world').resolves.toBe('hello sunshine');

expect(new Promise(r => r(0))).toThrow('oh noes!');
```

```ts
expect('hello world').toBe('hello sunshine');

expect(new Promise(r => r(0))).rejects.toThrow('oh noes!');
```

### Correct: the rule accepts this

```ts
declare function createPromiseLike(): PromiseLike<string>;

await expect(createPromiseLike()).resolves.toBe('hello sunshine');

interface MyThenable {
  then(onFulfilled: () => void, onRejected: () => void): MyThenable;
}

declare function createMyThenable(): MyThenable;

await expect(createMyThenable()).resolves.toBe('hello sunshine');
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import jest from "eslint-plugin-jest";

export default [
  {
    plugins: { jest },
    rules: {
      "jest/valid-expect-with-promise": "error",
    },
  },
];
```

## Related rules

- [jest/unbound-method](https://lintradar.dev/rules/jest/unbound-method.md): Enforce unbound methods are called with their expected scope
- [jest/valid-mock-module-path](https://lintradar.dev/rules/jest/valid-mock-module-path.md): Disallow mocking of non-existing module paths
- [jest/no-unnecessary-assertion](https://lintradar.dev/rules/jest/no-unnecessary-assertion.md): Disallow unnecessary assertions based on types
- [jest/no-error-equal](https://lintradar.dev/rules/jest/no-error-equal.md): Disallow using equality matchers on error types
- [jest/require-to-throw-message](https://lintradar.dev/rules/jest/require-to-throw-message.md): Require a message for `toThrow()`
- [jest/require-hook](https://lintradar.dev/rules/jest/require-hook.md): Require setup and teardown code to be within a hook

---

Web page: https://lintradar.dev/rules/jest/valid-expect-with-promise. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
