Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False alarms with require-hook, no-done-callback, and no-standalone-expect #182

Closed
mikestopcontinues opened this issue May 19, 2023 · 4 comments

Comments

@mikestopcontinues
Copy link

mikestopcontinues commented May 19, 2023

Here's some basic false alarms:

// eslint-disable-next-line vitest/require-hook
describe.skipIf(true)('suite', () => {
  test('test', async () => {
    expect(true).toBeTruthy();
  });
});

// eslint-disable-next-line vitest/require-hook
describe.concurrent('suite', () => {
  test('test', async () => {
    expect(true).toBeTruthy();
  });
});

Here's a larger example with three different false alarms (require-hook, no-done-callback, and no-standalone-expect):

import type {TestAPI, SuiteAPI} from 'vitest';
import {beforeEach, describe, test, expect} from 'vitest';

interface Context {
  value: string;
}

type ContextScope = {
  test: TestAPI<Context>;
  describe: SuiteAPI<Context>;
};

type ContextScopeFn = (scope: ContextScope) => void;

const withContext = (fn: ContextScopeFn) => {
  // eslint-disable-next-line vitest/no-done-callback
  beforeEach<Context>((ctx) => {
    ctx.value = Math.random();
  });

  fn({
    test: test as TestAPI<Context>,
    describe: describe as SuiteAPI<Context>,
  });
};

// eslint-disable-next-line vitest/require-hook
withContext(({describe, test}) => {
  describe('scraping', () => {
    test('it scrapes', async ({value}) => {
      // eslint-disable-next-line vitest/no-standalone-expect
      expect(value).toBeTruthy();
    });
  });
});
@mikestopcontinues mikestopcontinues changed the title require-hook false alarms in three cases... False alarms with require-hook, no-done-callback, and no-standalone-expect May 19, 2023
@SalahAdDin
Copy link

We are in September and we still have this issue:
image

@veritem
Copy link
Member

veritem commented Sep 27, 2023

@SalahAdDin I have so much todo with less time. I'll hopefully fix this sooner

@SalahAdDin
Copy link

I think it was our mistake: I forgot to add the types to tscofing file, after doing this, it seems all the false alarms disappeared.

@veritem
Copy link
Member

veritem commented Sep 28, 2023

@SalahAdDin if that's the case I'll go a head and close this issue. If it happens in future you can reopen again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants