mirror of
https://github.com/aleleba/create-react-component-library.git
synced 2025-07-21 03:58:17 -06:00
PR-440978: Adding Cypress Component Testing.
This commit is contained in:
2
src/@types/custom.d.ts
vendored
2
src/@types/custom.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
declare module "*.svg" {
|
||||
const content: any;
|
||||
export default content;
|
||||
}
|
||||
}
|
||||
|
14
src/components/__tests__/Card.test.cy.tsx
Normal file
14
src/components/__tests__/Card.test.cy.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import { Card } from '@components';
|
||||
|
||||
describe('Testing Card Component', () => {
|
||||
beforeEach(() => {
|
||||
cy.mount(<Card title='Test Title'><p>Test Content</p></Card>);
|
||||
})
|
||||
it('Show Title', () => {
|
||||
cy.get('div').contains('Test Title');
|
||||
})
|
||||
it('Show Child Component', () => {
|
||||
cy.get('p').contains('Test Content');
|
||||
})
|
||||
})
|
@ -1,20 +1,24 @@
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { Card } from '../Card';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { Card } from '@components';
|
||||
|
||||
describe('<App/> Component', () => {
|
||||
beforeEach(() => {
|
||||
fetchMock.resetMocks();
|
||||
// fetchMock.resetMocks();
|
||||
render(<Card title='Test Title'><p>Test Content</p></Card>)
|
||||
});
|
||||
|
||||
test('Should render <Card /> Component', async () => {
|
||||
fetchMock.mockResponseOnce(JSON.stringify({
|
||||
it('Show Title', async () => {
|
||||
/* fetchMock.mockResponseOnce(JSON.stringify({
|
||||
//First Data Fetch
|
||||
data: 'data'
|
||||
}));
|
||||
|
||||
render(
|
||||
<Card title='Test Title'><p>Test Content</p></Card>
|
||||
)
|
||||
})); */
|
||||
screen.getByText('Test Title')
|
||||
})
|
||||
})
|
||||
it('Show Child Component', async () => {
|
||||
/* fetchMock.mockResponseOnce(JSON.stringify({
|
||||
//First Data Fetch
|
||||
data: 'data'
|
||||
})); */
|
||||
screen.getByText('Test Content')
|
||||
})
|
||||
})
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React from 'react';
|
||||
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
||||
|
||||
import { Card } from '@components/Card';
|
||||
import { Card } from '@components';
|
||||
|
||||
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
||||
export default {
|
||||
|
Reference in New Issue
Block a user