@gluedigital/universal-plugin-jest
v1.1.1
Published
Jest configuration to enable Jest on universal-scripts
Readme
Universal Plugin Jest
This is a plugin for the universal-scripts framework. It provides configuration for running tests with Jest in Universal-based projects.
Features
- Preconfigured setup for running tests with Jest.
- Supports unit and integration testing in React applications.
- Fully compatible with TypeScript and
SWCfor faster builds. - Works with
@testing-library/reactand@testing-library/jest-domfor component testing (optional).
Installation
To install the plugin, run:
yarn add @gluedigital/universal-plugin-jestIf using npm
npm install @gluedigital/universal-plugin-jestNow you can execute the tests with:
yarn testIf using npm
npm run testIf you need to test React components, you can install @testing-library/react and @testing-library/jest-dom for additional utilities:
yarn add -D @testing-library/react @testing-library/jest-domIf using npm
npm install -D @testing-library/react @testing-library/jest-domOnce installed, you can import them in your tests:
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import MyComponent from "./MyComponent";
test("renders the component correctly", () => {
render(<MyComponent />);
expect(screen.getByText("Hello, Jest!")).toBeInTheDocument();
});Why Use This Plugin?
- Plug & Play: No need for complex Jest configurations—just install and start testing.
- Performance Optimized: Uses SWC for faster transformations.
- Flexible: Works with both JavaScript and TypeScript projects.
