Closed normanaranez closed 5 months ago
Hello @normanaranez. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction
will be closed if they have no activity within 3 days.
Describe the bug
when i run bun test --ui it works but when i run bun test only it doesn't.
it also works with "npm run test", "yarn test", i don't know why it doesn't run with bun test
`╭─ ~/Development/Redrain/RedviewPlatformAdministrationWeb main !3 ?2 ───── ✔ 3.12.1 20.11.1 02:40:09 PM ╰─ bun test bun test v1.1.3 (2615dc74)
tests/main.test.ts: ✓ adds 1 + 2 to equal 3 [0.23ms]
tests/components/button.test.tsx: 234 | throw error; 235 | } 236 | if (!baseElement) { 237 | // default to document.body instead of documentElement to avoid output of potentially-large 238 | // head elements (such as JSS style blocks) in debug output 239 | baseElement = document.body; ^ ReferenceError: Can't find variable: document at render (/Users/normanaranez/Development/Redrain/RedviewPlatformAdministrationWeb/node_modules/@testing-library/react/dist/pure.js:239:19) at /Users/normanaranez/Development/Redrain/RedviewPlatformAdministrationWeb/tests/components/button.test.tsx:10:9 ✗ Button > should render a button with the default variant [1.55ms]`
Reproduction
package.json
{ "name": "platform-web", "private": true, "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview", "test": "vitest", "test:ui": "vitest --ui", "compile": "bunx --bun vite build" }, "dependencies": { "@ag-grid-community/core": "^31.2.1", "@ag-grid-community/react": "^31.2.1", "@hookform/resolvers": "^3.3.4", "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-label": "^2.0.2", "@radix-ui/react-slot": "^1.0.2", "@reduxjs/toolkit": "^2.2.3", "ag-grid-community": "^31.2.1", "ag-grid-react": "^31.2.1", "class-variance-authority": "^0.7.0", "clsx": "^2.1.0", "lucide-react": "^0.368.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.51.3", "react-icons": "^5.0.1", "react-redux": "^9.1.1", "react-router-dom": "^6.22.3", "tailwind-merge": "^2.2.2", "tailwindcss-animate": "^1.0.7", "zod": "^3.22.4" }, "devDependencies": { "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^15.0.2", "@types/jsdom": "^21.1.6", "@types/node": "^20.12.7", "@types/react": "^18.2.66", "@types/react-dom": "^18.2.22", "@typescript-eslint/eslint-plugin": "^7.2.0", "@typescript-eslint/parser": "^7.2.0", "@vitejs/plugin-react-swc": "^3.5.0", "@vitest/ui": "^1.5.0", "autoprefixer": "^10.4.19", "eslint": "^8.57.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.6", "jsdom": "^24.0.0", "postcss": "^8.4.38", "tailwindcss": "^3.4.3", "typescript": "^5.2.2", "vite": "^5.2.0", "vitest": "^1.5.0" }, "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610" }
button.test.tsx
import { describe, expect, it } from 'vitest'; import { render, screen } from '@testing-library/react'; import React from 'react'; import { Button } from '../../src/components/ui/button'; import '@testing-library/jest-dom/vitest';
describe('Button', () => { it('should render a button with the default variant', () => {
});
System Info
Used Package Manager
npm
Validations