݁߹ςετ
• "୯ମ"Λ͑ͯෳͷίϯϙʔωϯτΛΈ߹
Θͤͨςετͷ͜ͱ
export const Greeting = () => {
const [showGreeting, setShowGreeting] = useState(false);
return (
{showGreeting &&
sayHello()}
setShowGreeting(true)}>Show Greeting
button>
);
};
test('shows correct greeting', () => {
const screen = render();
const greeting = screen.getByTestId('greeting');
const button = screen.getByTestId('show-greeting-
button');
expect(greeting.textContent).toBe('');
fireEvent.click(button);
expect(greeting.textContent).toBe('Hello
human!');
});