2.52.0 • Published 2 years ago

@homebound/rtl-utils v2.52.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

rtl-utils

Common test helpers for use with React Testing Library.

rtl-utils provides syntax sugar for rendering a Component in RTL with app-specific state/wrapper components, as well as some convenience methods for generating test events. Some common wrappers are also included.

Examples

Router wrapper

atUrl will wrap a test component in a MemoryRouter at a specific URL, e.g.

import { atUrl, render } from "@homebound/rtl-utils";

...

await render(<ContactPanel {...props} />, atUrl("/contact"));

Apollo wrapper

Returns an Apollo provider that will respond with the mocks responses.

import { render, withApollo } from "@homebound/rtl-utils";

...

const apollo = withApollo([
  newEstimateResponse(),
  newTestSaveLeadResponse({ data: { errorMessage: "error happened" } }),
]);
const c = await render(<GraphQLPage {...props} />, apollo);

History wrapper

Returns a Router wrapper with a its history prop set to newHistoryMock if the user does not provide a history mock of their own.

import { render, withHistory } from "@homebound/rtl-utils";
import { newHistoryMock } from "../auth/testHistory";

...

const c = await render(<ScheduleTable {...props} />, withHistory(historyMock));
2.52.0

2 years ago

2.51.0

3 years ago

2.49.0

3 years ago

2.50.0

3 years ago

2.48.0

3 years ago

2.47.0

3 years ago

2.46.0

3 years ago

2.45.0

3 years ago

2.44.0

3 years ago

2.43.0

3 years ago

2.42.0

3 years ago

2.41.0

3 years ago

2.40.0

3 years ago

1.0.0

3 years ago

1.39.0

3 years ago

1.38.0

3 years ago

1.37.0

4 years ago

1.36.0

4 years ago

1.35.0

4 years ago

1.34.0

4 years ago

1.33.0

4 years ago

1.32.0

4 years ago

1.31.0

4 years ago

1.30.0

4 years ago

1.29.0

4 years ago

1.28.0

4 years ago

1.27.0

4 years ago

1.26.0

4 years ago

1.24.0

4 years ago

1.23.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.22.0

4 years ago

1.21.0

4 years ago

1.20.0

4 years ago

1.19.0

4 years ago

1.18.0

4 years ago

1.17.0

4 years ago

1.16.0

4 years ago

1.15.0

4 years ago

1.14.0

4 years ago

1.13.0

4 years ago

1.12.0

4 years ago

1.11.0

4 years ago

1.10.0

4 years ago

1.9.0

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago