jest-dom
user-event
Our great sponsors
jest-dom | user-event | |
---|---|---|
22 | 5 | |
4,284 | 2,113 | |
0.9% | 0.8% | |
7.0 | 5.6 | |
4 days ago | about 2 months ago | |
JavaScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
jest-dom
-
Mastering Jest Configuration for React TypeScript Projects with Vite: A Step-by-Step Guide
//config/jest/setupTests.ts // jest-dom adds custom jest matchers for asserting on DOM nodes. // allows you to do things like: // expect(element).toHaveTextContent(/react/i) // learn more: https://github.com/testing-library/jest-dom import '@testing-library/jest-dom';
-
Anyone have setup instructions for Vitest + Typescript + React testing library? My setup is failing to extend matchers on Vitest Types
Update: Just got it working. Following the instructions on this github issue and using `shamefully-hoist=true` with pnpm I got it working. The issue I was facing was with pnpm.
-
Is there a jest query method for this use case?
React Testing Library uses jest-dom which has a .getByText() matcher.
-
Setting Up a Modern Preact Application With Typescript, Vite and Vitest
vitest-dom extends the standard Jest matchers with convenient methods like .toBeDisabled. Now you can write tests that assert on the state of the DOM. The package is a fork of @testing-library/jest-dom.
-
Superset: Testing and Enzyme to RTL conversion
jest-dom matchers
-
Migrating from Jest to Vitest
At the time of writing this article, it still seems to be an open issue. However, a workaround I found is to add "skipLibCheck": true, to your tsconfig.json file.
- Buenas prácticas con Angular Testing Library
-
Unable to test React-Redux Toolkit app
// jest-dom adds custom jest matchers for asserting on DOM nodes. // allows you to do things like: // expect(element).toHaveTextContent(/react/i) // learn more: https://github.com/testing-library/jest-dom import '@testing-library/jest-dom'; import { server } from './mocks/server'; beforeAll( () => server.listen( { onUnhandledRequest: 'error' } ) ); afterEach( () => server.resetHandlers() ); afterAll( () => server.close() );
-
Setup Jest to React Typescript Vite project, also SWC (part 1)
Everything you want to do to your test environment such as extends the jest matchers with @testing-library/jest-dom, mock some APIs that’s not implemented in jdom, you can put to config/jest/setupTests.js:
-
Svelte test suite setup
This will register the additional assertions from @testing-library/jest-dom.
user-event
-
How do I test a button that change a state with jest ?
You probably want to be using user-event instead of fireEvent.
-
Mocking setTimeout with Jest
With userEvent it is different. Since version 14.0.0 the APIs always return a Promise. Because of that we need to make the whole test async and await on clicking with userEvent.
-
BDD and TDD testing for React-Node App
I just learned to do TDD by react testing library + jest + user event https://github.com/testing-library/user-event
-
Django, HTMX and Alpine.js: Modern Websites, JavaScript Optional
I just tried running WinDirStat on the `node_modules` folder in a Create-React-App project I had lying around. Total size was 234 MB. Of that, 129MB was JS files. By far the biggest piece was TypeScript, which has 45MB of .js in 6 files making up its parsing and IDE language service implementation.
Beyond that, the breakdown is:
- .ts source files: 25MB
- Sourcemaps: 23MB
- Markdown: 15MB
- JSON: 10MB
It also looks like there's a 12MB Linux binary that was only in there as a publishing accident for the `user-event` library that has since been resolved ( https://github.com/testing-library/user-event/issues/266 ).
Or, take Redux Toolkit, which I maintain. If you look at https://unpkg.com/browse/@reduxjs/[email protected]/ , the published package for our current version, it adds up to about 10MB on disk. But, that's because we ship three separate entry points (RTK core, RTK Query UI-agnostic core, RTK Query with React-specific additions), and for each entry point we compile the code to multiple file formats (CommonJS, ESM legacy, ESM modern, ESM with "dev" and "prod" already built in, UMD dev, UMD production), and each of those has sourcemaps. The actual amount of code that ends up in your bundle is about 20KB min+gz.
So, it's a combination of many things: TS itself is big, libraries typically publish packages containing both the original source code plus multiple build artifacts to run in different environments, and packages also include various metadata and other files as well.
-
Comparing Enzyme with React Testing Library
To get away from testing our code implementation and get closer to testing how the application is actually used, we turn once again to React Testing Library. Instead of creating fake DOM event objects and simulating various change events, we have the ability to mimic how users would actually interact with the application using userEvent's, which are provided by the user-event library.
What are some alternatives?
jest - Delightful JavaScript Testing.
testing-with-enzyme
msw - Seamless REST/GraphQL API mocking library for browser and Node.js.
django-unicorn - The magical reactive component framework for Django ✨
Cypress - Fast, easy and reliable testing for anything that runs in a browser.
angular-testing-library - 🐙 Simple and complete Angular testing utilities that encourage good testing practices
jest-cheat-sheet - Jest cheat sheet
callbag-jsx - callbags + JSX: fast and tiny interactive web apps
husky - Git hooks made easy 🐶 woof!
blog_mocking_settimeout_with_jest - Mocking setTimeout with Jest
jest-axe - Custom Jest matcher for aXe for testing accessibility ♿️🃏
testing-with-react-testing-library