Skip to content

React ViteJs template configured with typescript, eslint, prettier, husky (pre-commit), storybook, jest, testing-library and more...

Notifications You must be signed in to change notification settings

Aleydon/React-Vite

Repository files navigation

🌎 Vite.js Template 🌎


logo of React-Vite repository

📌 Requirements: 📌

NodeJs: 🔗 https://nodejs.org/en/


▶️ Get Started:

  1. Clone this repo
git clone https://github.com/Aleydon/React-Vite.git
  1. Install NPM packages
npm install or yarn install
  1. Run this project
npm run dev or yarn dev

Template configuration:


Tests + Storybook:

  • How to run tests:
npm run test or npm run test:watch

It has an example of tests with Jest + Testing-Library in src/App.spec.tsx

import { render, screen } from '@testing-library/react';

import App from './App';

describe('App Component', () => {
	it('should get the text hello world', () => {
		render(<App />);
		const hello = screen.getByText('Hello World');
		expect(hello).toBeDefined();
	});

	it('should get the text hello world in the component s heading', () => {
		render(<App />);
		const heading = screen.getByRole('heading', {
			name: 'Hello World'
		});
		expect(heading).toBeInTheDocument();
	});

	it('must get the link from the App component', () => {
		render(<App />);
		const link = screen.getByRole('link', { name: 'github.com/Aleydon' });
		expect(link).toBeDefined();
		expect(link).toHaveAttribute('target', '_blank');
		expect(link).toHaveAttribute('aria-label', 'github.com/Aleydon');
	});
});

  • How to run storybook:
npm run storybook or yarn storybook


storybook running

also has an example of using Storybook in the Text component in src/components/Text/text.stories.tsx

import type { Meta, StoryObj } from '@storybook/react';

import Text, { type TextProps } from '.';

const text: Meta<typeof Text> = {
	component: Text,
	title: 'Components/Text'
};

export default text;

export const Small: StoryObj<TextProps> = {
	args: {
		size: 'small',
		children: 'Small Text'
	}
};

export const Medium: StoryObj<TextProps> = {
	args: {
		size: 'medium',
		children: 'Medium Text'
	}
};
export const Large: StoryObj<TextProps> = {
	args: {
		size: 'large',
		children: 'Large Text'
	}
};