This commit is contained in:
+20
-1
@@ -1,2 +1,21 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import ExampleComponent from '../ExampleComponent';
|
||||
|
||||
// import nicht notwendig ( Findet automatisch durch globale Setting statt)
|
||||
import { test, it, expect } from 'vitest';
|
||||
|
||||
// Test case
|
||||
test('Component renders correctly and contains text "Hello World"');
|
||||
// it('should render correctly and contains text "Hello World"', () => {})
|
||||
test('Component renders correctly and contains text "Hello World"', () => {
|
||||
// AAA - Arrange, Act, Assert
|
||||
|
||||
// Arrange
|
||||
render(<ExampleComponent />);
|
||||
|
||||
const element = screen.getByText(/Hello World/i);
|
||||
|
||||
// Act - Assert
|
||||
expect(element).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// console.log(document.querySelector('p').textContent.includes('Hello World')); // => true
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import ExampleComponent from '../components/ExampleComponent';
|
||||
|
||||
// import nicht notwendig ( Findet automatisch durch globale Setting statt)
|
||||
import { test, it, expect } from 'vitest';
|
||||
|
||||
// Test case
|
||||
// it('should render correctly and contains text "Hello World"', () => {})
|
||||
test('Component renders correctly and contains text "Hello World"', () => {
|
||||
// AAA - Arrange, Act, Assert
|
||||
|
||||
// Arrange
|
||||
render(<ExampleComponent />);
|
||||
|
||||
const element = screen.getByText(/Hello World/i);
|
||||
|
||||
// Act - Assert
|
||||
expect(element).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// console.log(document.querySelector('p').textContent.includes('Hello World')); // => true
|
||||
Reference in New Issue
Block a user