Skip to content

Commit

Permalink
deps: add @storybook/test-runner as dev dependnecy
Browse files Browse the repository at this point in the history
  • Loading branch information
DaleSeo committed Dec 11, 2024
1 parent f883d49 commit d9201ee
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
26 changes: 13 additions & 13 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";

export default tseslint.config(
{ ignores: ['dist'] },
{ ignores: ["dist", "styled-system"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
},
)
}
);
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"sb": "storybook dev -p 6006",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test-storybook": "test-storybook",
"prepare": "panda codegen"
},
"dependencies": {
Expand All @@ -30,6 +31,7 @@
"@storybook/react": "^8.4.6",
"@storybook/react-vite": "^8.4.6",
"@storybook/test": "^8.4.6",
"@storybook/test-runner": "^0.20.1",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
Expand Down
23 changes: 23 additions & 0 deletions src/components/Button/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { expect, describe, it, vi } from "vitest";
import { Button } from "./Button";

describe("<Button>", () => {
it("renders a button with text", () => {
render(<Button>Click</Button>);

expect(screen.getByRole("button")).toHaveTextContent("Click");
});

it("calls onClick handler when clicked", async () => {
const user = userEvent.setup();
const handleClick = vi.fn();

render(<Button onClick={handleClick}>Click</Button>);

await user.click(screen.getByRole("button"));

expect(handleClick).toHaveBeenCalledTimes(1);
});
});

0 comments on commit d9201ee

Please sign in to comment.