- Fix @tailwindcss/oxide Native Binding Error in pnpm Workspace with Next.js· 4 min read
Getting 'Cannot find native binding' for @tailwindcss/oxide in a pnpm workspace with Next.js Turbopack? Here's why it happens and how to fix it.
- How to Trigger React Error Boundary (Dev and Test)· 4 min read
Trigger a React error boundary by throwing during render, testing the fallback in Jest, and using showBoundary for async or event-handler errors.
- Mock IntersectionObserver in Jest Setup· 4 min read
Fix `IntersectionObserver is not defined` in Jest by adding a clean global mock in `jest.setup.ts`. Includes TypeScript-safe setup and a test example.
- Check If Clicked Element Is Descendant Close On Click Outside· 3 min read
Detect a click outside a modal or dropdown in React with Node.contains(), and close it by checking if the clicked element is a descendant.
- Eslint Enforce Named Function In Useeffect· 2 min read
Enforce named functions inside useEffect for better debugging and stack traces.
- Fix "Property 'value' does not exist on type 'EventTarget'"· 2 min read
TypeScript types event.target as EventTarget, which has no value. Use React.ChangeEvent<HTMLInputElement> or cast the target to HTMLInputElement.
- Fix useRef "Property does not exist on type 'never'"· 2 min read
useRef(null) without a type argument leaves ref.current typed as 'never'. Pass the element type, like useRef<HTMLInputElement>(null), to fix it.
- Fix Jest "window.matchMedia is not a function"· 3 min read
jsdom in Jest has no window.matchMedia, so components that call it throw a TypeError. Add a matchMedia mock to your Jest setup file.
- How to Handle CORS When Using json-server· 3 min read
Fix CORS errors in json-server with a custom server.js and middleware. Covers preflight OPTIONS requests and when to use wildcard vs specific origin.
- 5 Examples of Applications for Learning JavaScript· 10 min read
Discover 5 simple applications to enhance your JavaScript skills. Dive deeper into learning by trying out these JavaScript examples today!
- Fixing Jest Error: 'Not Implemented window.scrollTo'· 1 min read
Fix the Jest jsdom error "Not implemented: window.scrollTo" by mocking window.scrollTo in your setup file. Includes a test to confirm that the mock works.
- How to Solve the "ResizeObserver is Not Defined" Error in Jest Tests· 2 min read
Fix "ResizeObserver is not defined" in Jest by mocking ResizeObserver in your setup file, so tests for components that use it run in jsdom.
- Testing Next.js Image Component· 3 min read
Simple way to test Next.js Image in Jest by mocking it as a plain img tag, plus checks and common mistakes.
- Testing the next-i18next Library with Jest· 2 min read
Simple way to test next-i18next in Jest by mocking translation hooks so component tests stay focused and stable.
- How to Resolve 'Cannot use import statement outside a module' Error when Mocking Swiper JS with Jest· 2 min read
Fix Jest "Cannot use import statement outside a module" when mocking Swiper by adjusting transformIgnorePatterns.
- Resolving Jest Error with EMFILE Too Many Open Files· 2 min read
Fix the Jest EMFILE too many open files error by lowering maxWorkers, ignoring build folders, raising ulimit, and running in band on CI.
- Comprehensive Guide: Mocking Next.js useRouter with Jest for Effective Testing· 2 min read
Mock Next.js useRouter in Jest with reliable patterns for pathname, query, and push assertions in component tests.
- Setup Nodemon with Babel· 2 min read
Easily start node project by using nodemon and babel
- Webpack Configuration: Including Specific Moment.js Locale· 2 min read
How to keep only specific Moment.js locales in Webpack to reduce bundle size and avoid loading every locale.
- Debugging 'window.scrollTo' Invocation for Identifying the Caller· 1 min read
Find exactly where window.scrollTo is called in Jest tests using console.trace, jest.spyOn, and a few quick steps to narrow down the caller.