mirror of
https://github.com/supabase/supabase.git
synced 2026-12-05 16:09:06 +00:00
## Problem - `apps/studio/tests/setup/radix.js` holds the jsdom stubs for `ResizeObserver` and `scrollIntoView` but nothing in it is specific to radix - studio already keeps its jsdom stubs in `tests/setup/polyfills.ts` ## Solution - moves the `ResizeObserver` and `scrollIntoView` stubs into `tests/setup/polyfills.ts` + removes `radix.js` from the vitest setup files - changes the studio-testing skill to name the one dom setup file that remains <!-- ## Preview links If relevant, include links to changed pages for easy review access. Copy the preview base URL from the Vercel bot comment on this PR. Use the following table as an example template. | Site | Live | Preview | Search for | | -------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- | | WWW | [/blog/your-post](https://supabase.com/blog/your-post) | [/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post) | unique phrase from the change | | Docs | [/docs/guides/your-page](https://supabase.com/docs/guides/your-page) | [/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page) | unique phrase from the change | | Studio | [/dashboard](https://supabase.com/dashboard) | [/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard) | unique phrase from the change | | Design system | [/design-system](https://supabase.com/design-system) | [/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system) | unique phrase from the change | | UI library | [/library](https://supabase.com/library) | [/library](https://ui-library-git-branch-name-supabase.vercel.app/library) | unique phrase from the change | | Knowledge base | [/kb/guides/your-page](https://supabase.com/kb/guides/your-page) | [/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page) | unique phrase from the change | --> <!-- ## Additional context Optionally add any other context or screenshots. --> ## Review instructions 1. run `pnpm test:studio` and make sure that the run reports no unhandled errors 2. make sure that the failures are the same as on `master` ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
69 lines
2.4 KiB
TypeScript
69 lines
2.4 KiB
TypeScript
import { resolve } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import react from '@vitejs/plugin-react'
|
|
import { configDefaults, defineConfig } from 'vitest/config'
|
|
|
|
// Some tools like Vitest VSCode extensions, have trouble with resolving relative paths,
|
|
// as they use the directory of the test file as `cwd`, which makes them believe that
|
|
// `setupFiles` live next to the test file itself. This forces them to always resolve correctly.
|
|
const dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
|
|
const IS_CI = !!process.env.CI
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
tsconfigPaths: true,
|
|
alias: {
|
|
'@ui': resolve(dirname, './../../packages/ui/src'),
|
|
},
|
|
},
|
|
test: {
|
|
globals: true,
|
|
// Retry flaky tests in CI only; failures locally should surface immediately.
|
|
retry: IS_CI ? 2 : 0,
|
|
// The DOM setup file (`dom.ts`) no-ops when there's no jsdom environment.
|
|
setupFiles: [
|
|
resolve(dirname, './tests/setup/dom.ts'),
|
|
resolve(dirname, './tests/vitestSetup.ts'),
|
|
],
|
|
// Don't look for tests in the nextjs output directory
|
|
exclude: [...configDefaults.exclude, `.next/*`],
|
|
// jsdom costs ~1s of setup per file, so pure-logic `.test.ts` files run in node.
|
|
// A `.test.ts` file that needs the DOM (e.g. `renderHook`) opts in with a
|
|
// `// @vitest-environment jsdom` docblock at the top of the file.
|
|
projects: [
|
|
{ extends: true, test: { name: 'node', environment: 'node', include: ['**/*.test.ts'] } },
|
|
{
|
|
extends: true,
|
|
test: {
|
|
name: 'jsdom',
|
|
environment: 'jsdom',
|
|
include: ['**/*.test.tsx'],
|
|
exclude: [...configDefaults.exclude, '.next/*', '**/*.platform.test.tsx'],
|
|
},
|
|
},
|
|
{
|
|
extends: true,
|
|
test: {
|
|
name: 'jsdom-platform',
|
|
environment: 'jsdom',
|
|
include: ['**/*.platform.test.tsx'],
|
|
exclude: [...configDefaults.exclude, '.next/*'],
|
|
env: { NEXT_PUBLIC_IS_PLATFORM: 'true' },
|
|
},
|
|
},
|
|
],
|
|
reporters: [['default']],
|
|
coverage: {
|
|
reporter: ['text', 'text-summary', 'lcov'],
|
|
exclude: [
|
|
'**/*.test.ts',
|
|
'**/*.test.tsx',
|
|
'**/base64url.ts', // [Jordi] Tests for this file exist in https://github.com/supabase-community/base64url-js/blob/main/src/base64url.test.ts so we can ignore.
|
|
],
|
|
include: ['lib/**/*.ts'],
|
|
},
|
|
},
|
|
})
|