epic-stack icon indicating copy to clipboard operation
epic-stack copied to clipboard

Disable "global" in vitest

Open kentcdodds opened this issue 1 year ago • 4 comments

I tried and ran into TS issues. Would love to ditch it though.

kentcdodds avatar May 11 '23 04:05 kentcdodds

@kentcdodds

Can you provide the draft you are working on?

I will try to work on in

onemen avatar May 19 '23 05:05 onemen

I didn't save it. There wasn't much to it. Just remove some stuff from the vitest config and the tsconfig and things stopped working 😅 I didn't spend much time on it I'm afraid.

kentcdodds avatar May 19 '23 17:05 kentcdodds

do you want to remove:

globals from vitest.config.ts:

  plugins: [react(), tsconfigPaths()],
  test: {
    include: ['./app/**/*.test.{ts,tsx}'],
-    globals: true,
    environment: 'jsdom',
    setupFiles: ['./other/test-setup/setup-test-env.ts'],
    globalSetup: ['./other/test-setup/global-setup.ts'],

or global from setup-test-env.ts

declare global {
  namespace Vi {
    interface JestAssertion<T = any>
      extends jest.Matchers<void, T>,
        TestingLibraryMatchers<T, void> {}
  }
}

or ...

onemen avatar May 19 '23 18:05 onemen

I guess I would like to remove the global test and expect but still have the testing library matchers if that's possible. It may require that we import test and expect from the vitest utils which is similar to what we do with playwright

kentcdodds avatar May 19 '23 18:05 kentcdodds