---
source: crates/oxc_linter/src/tester.rs
assertion_line: 216
---
  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:34]
 2 │                 it('foo', () => {
 3 │                     something && expect(something).toHaveBeenCalled();
   ·                                  ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:31]
 2 │                 it('foo', () => {
 3 │                     a || b && expect(something).toHaveBeenCalled();
   ·                               ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:33]
 2 │                 it('foo', () => {
 3 │                     (a || b) && expect(something).toHaveBeenCalled();
   ·                                 ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:32]
 2 │                 it('foo', () => {
 3 │                     a || (b && expect(something).toHaveBeenCalled());
   ·                                ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:31]
 2 │                 it('foo', () => {
 3 │                     a && b && expect(something).toHaveBeenCalled();
   ·                               ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:31]
 2 │                 it('foo', () => {
 3 │                     a && b || expect(something).toHaveBeenCalled();
   ·                               ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:33]
 2 │                 it('foo', () => {
 3 │                     (a && b) || expect(something).toHaveBeenCalled();
   ·                                 ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:34]
 2 │                 function getValue() {
 3 │                     something && expect(something).toHaveBeenCalled();
   ·                                  ──────
 4 │                 }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:34]
 2 │                 it('foo', () => {
 3 │                     something || expect(something).toHaveBeenCalled();
   ·                                  ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:34]
 2 │                 it.each``('foo', () => {
 3 │                     something || expect(something).toHaveBeenCalled();
   ·                                  ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:34]
 2 │                 it.each()('foo', () => {
 3 │                     something || expect(something).toHaveBeenCalled();
   ·                                  ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:34]
 2 │                 function getValue() {
 3 │                     something || expect(something).toHaveBeenCalled();
   ·                                  ──────
 4 │                 }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:33]
 2 │                 it('foo', () => {
 3 │                     something ? expect(something).toHaveBeenCalled() : noop();
   ·                                 ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:33]
 2 │                 function getValue() {
 3 │                     something ? expect(something).toHaveBeenCalled() : noop();
   ·                                 ──────
 4 │                 }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:42]
 2 │                 it('foo', () => {
 3 │                     something ? noop() : expect(something).toHaveBeenCalled();
   ·                                          ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:42]
 2 │                 it.each``('foo', () => {
 3 │                     something ? noop() : expect(something).toHaveBeenCalled();
   ·                                          ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:42]
 2 │                 it.each()('foo', () => {
 3 │                     something ? noop() : expect(something).toHaveBeenCalled();
   ·                                          ──────
 4 │                 })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:42]
 2 │                 function getValue() {
 3 │                     something ? noop() : expect(something).toHaveBeenCalled();
   ·                                          ──────
 4 │                 }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:7:25]
 6 │                     default:
 7 │                         expect(something).toHaveBeenCalled();
   ·                         ──────
 8 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:5:25]
 4 │                     case 'value':
 5 │                         expect(something).toHaveBeenCalled();
   ·                         ──────
 6 │                     default:
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:5:25]
 4 │                     case 'value':
 5 │                         expect(something).toHaveBeenCalled();
   ·                         ──────
 6 │                     default:
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:5:25]
 4 │                     case 'value':
 5 │                         expect(something).toHaveBeenCalled();
   ·                         ──────
 6 │                     default:
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:7:25]
 6 │                     default:
 7 │                         expect(something).toHaveBeenCalled();
   ·                         ──────
 8 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:4:25]
 3 │                     if(doSomething) {
 4 │                         expect(something).toHaveBeenCalled();
   ·                         ──────
 5 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:6:25]
 5 │                     } else {
 6 │                         expect(something).toHaveBeenCalled();
   ·                         ──────
 7 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:6:25]
 5 │                     } else {
 6 │                         expect(something).toHaveBeenCalled();
   ·                         ──────
 7 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:6:25]
 5 │                     } else {
 6 │                         expect(something).toHaveBeenCalled();
   ·                         ──────
 7 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:4:25]
 3 │                     if(doSomething) {
 4 │                         expect(something).toHaveBeenCalled();
   ·                         ──────
 5 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:6:21]
 5 │                     } else {
 6 │                     expect(something).toHaveBeenCalled();
   ·                     ──────
 7 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:6:21]
 5 │                     } catch (err) {
 6 │                     expect(err).toMatch('Error');
   ·                     ──────
 7 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:6:21]
 5 │                     } catch (err) {
 6 │                     expect(err).toMatch('Error');
   ·                     ──────
 7 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:6:25]
 5 │                     } catch (err) {
 6 │                         expect(err).toMatch('Error');
   ·                         ──────
 7 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:6:25]
 5 │                     } catch (err) {
 6 │                         expect(err).toMatch('Error');
   ·                         ──────
 7 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:6:25]
 5 │                     } catch (err) {
 6 │                         expect(err).toMatch('Error');
   ·                         ──────
 7 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:6:21]
 5 │                     } catch {
 6 │                     expect(something).toHaveBeenCalled();
   ·                     ──────
 7 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:5:37]
 4 │                     .then(() => { throw new Error('oh noes!'); })
 5 │                     .catch(error => expect(error).toBeInstanceOf(Error));
   ·                                     ──────
 6 │                 });
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
    ╭─[no_conditional_expect.tsx:9:37]
  8 │                     .then(() => { throw new Error('oh noes!'); })
  9 │                     .catch(error => expect(error).toBeInstanceOf(Error));
    ·                                     ──────
 10 │                 });
    ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:7:37]
 6 │                     .then(() => { throw new Error('oh noes!'); })
 7 │                     .catch(error => expect(error).toBeInstanceOf(Error))
   ·                                     ──────
 8 │                     .then(() => { throw new Error('oh noes!'); })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:5:37]
 4 │                     .then(() => { throw new Error('oh noes!'); })
 5 │                     .catch(error => expect(error).toBeInstanceOf(Error))
   ·                                     ──────
 6 │                     .then(() => { throw new Error('oh noes!'); })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:6:32]
 5 │                         .catch(error => expect(error).toBeInstanceOf(Error))
 6 │                         .catch(error => expect(error).toBeInstanceOf(Error));
   ·                                         ──────
 7 │                     });
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:5:32]
 4 │                         .catch(error => expect(error).toBeInstanceOf(Error))
 5 │                         .catch(error => expect(error).toBeInstanceOf(Error))
   ·                                         ──────
 6 │                         .catch(error => expect(error).toBeInstanceOf(Error));
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:4:32]
 3 │                       await Promise.resolve()
 4 │                         .catch(error => expect(error).toBeInstanceOf(Error))
   ·                                         ──────
 5 │                         .catch(error => expect(error).toBeInstanceOf(Error))
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:4:37]
 3 │                     await Promise.resolve()
 4 │                     .catch(error => expect(error).toBeInstanceOf(Error))
   ·                                     ──────
 5 │                     .then(() => { throw new Error('oh noes!'); })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:5:37]
 4 │                     .then(() => { throw new Error('oh noes!'); })
 5 │                     .catch(error => expect(error).toBeInstanceOf(Error));
   ·                                     ──────
 6 │                 });
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:54]
 2 │                 it('works', async () => {
 3 │                     await somePromise.catch(error => expect(error).toBeInstanceOf(Error));
   ·                                                      ──────
 4 │                 });
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:7:25]
 6 │                     if (vnode._nextDom) {
 7 │                         expect.fail('vnode should not have _nextDom:' + vnode._nextDom);
   ·                         ──────
 8 │                     }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:30]
 2 │             it('foo', () => {
 3 │                 something && expect(something).toHaveBeenCalled();
   ·                              ──────
 4 │             })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:28]
 2 │             it('foo', () => {
 3 │                 a || (b && expect(something).toHaveBeenCalled());
   ·                            ──────
 4 │             })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:30]
 2 │             it.each``('foo', () => {
 3 │                 something || expect(something).toHaveBeenCalled();
   ·                              ──────
 4 │             });
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:30]
 2 │             it.each()('foo', () => {
 3 │                 something || expect(something).toHaveBeenCalled();
   ·                              ──────
 4 │             })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:30]
 2 │             function getValue() {
 3 │                 something || expect(something).toHaveBeenCalled();
   ·                              ──────
 4 │             }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:29]
 2 │             it('foo', () => {
 3 │                 something ? expect(something).toHaveBeenCalled() : noop();
   ·                             ──────
 4 │             })
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:29]
 2 │             function getValue() {
 3 │                 something ? expect(something).toHaveBeenCalled() : noop();
   ·                             ──────
 4 │             }
   ╰────
  help: Avoid calling `expect` conditionally`

  ⚠ eslint-plugin-vitest(no-conditional-expect): Unexpected conditional expect
   ╭─[no_conditional_expect.tsx:3:38]
 2 │             it('foo', () => {
 3 │                 something ? noop() : expect(something).toHaveBeenCalled();
   ·                                      ──────
 4 │             })
   ╰────
  help: Avoid calling `expect` conditionally`
