npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-react-testing-boilerplate

v0.0.1

Published

Get started with react testing in vite-react template faster.

Readme

vite-react-testing-boilerplate

Execute npx create-vite-react-testing-boilerplate app-name command in the folder where you want your project, and voila you have your project


There are way to many boilerplate template for react but as far as I can say vite is most loved one , also it is fast (extra :) ), but if you want to learn test your react app, the most famous way to do is to create your react app with

npx create-react-app app-name

But the problem with this is, it takes a hell lot of time to start and also on every change it takes time to compile(also the state is not persisted, and there are many other problems, but let's not talk about them.)

So the main thing is, when I wanted to learn react testing with vitejs template, I face this issue, there were no boilerplate for that, and there is next to none information over the internet, to help you setup easily and get started with the testing part.

So I created this, (you need the specific version of the packages just to avoid crash or anything)

Let's get to the fun part (explanation of what every is doing)

"@babel/preset-env": "^7.19.4" @babel/preset-env is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, browser polyfills) are needed by your target environment(s). This both makes your life easier and JavaScript bundles smaller! (Copied for official website not really necessary to go deeper than this)

"@babel/preset-react": "^7.18.6" It it used when we work with react, it transpile our jsx code into React.createElement format, like <h1>Hello, world!</h1> this will be converted into

React.createElement(
   "h1",
   null,
   "Hello, world!"
);

and the runtime:"automatic" implies auto import the functions that jsx transpiles to (last line copied from official babel docs ;))

"@testing-library/react" react testing library provides you function to catch dom element and perform some action below are some of its function

render, fireEvent, waitFor, screen

"@testing-library/user-event": "^14.4.3" This package is used to fireEvent that users will do on your we website like click a button or type into input field.

"@testing-library/jest-dom": "^5.16.5" This package is also there, which is an extension of @testing-library/react which provides some custom matchers, which make it easier for jest and @testing-library/react to talk to each other (Is Girl friend's male best friend an idean example of this?).

"babel-jest": "^29.2.2" This plugin is used to declare that we will use babel as our transpiler with jest

"identity-obj-proxy": "^3.0.0" This package is used to mock css or sass files if present, for some reason if used anu stylesheet and not mocked it gives error, that's why its there (don't know more than this :')) "jest": "^29.2.2" Jets is a test runner, the simplest explanantion is @testing-library/react is a car, but to run the car you need key so jest is that key, in other words, with @testing-library/react your write your tests and with jest you run them and in package.json the test script is "jest --watchAll" --watchAll is used to watch the files, if any test files changes it will rerun the tests automatically.

jest-environment-jsdom": "^29.2.2" This is just a extra package we need to install in order to run the tests with jest as we aee using jsdom and in jest previous versions it was clubbed with jest, but now we install both of them separate.

Folder structure


├── public
│   └── vite.svg
├── src
│   ├── __mocks__
│   |    └── fileMock.js
│   ├── __tests__
│   |    └── App.test.js
│   └── assets
│   └── App.jsx
│   └── index.css
│   └── main.jsx
├── .gitignore
├── babel.config.js
├── jest.config.js
├── index.html
├── package.json
├── setupTests.js
├── vite.config.js
└── README.md