@trackunit/react-test-setup 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # Trackunit react-test-setup
2
+
3
+ Testing utility package that provides common setup functions for React applications. This library contains general setup files necessary for tests to run, which are not app-specific.
4
+
5
+ This library is exposed publicly for use in the Trackunit [Iris App SDK](https://www.npmjs.com/package/@trackunit/iris-app).
6
+
7
+ To browse all avaliable components visit our [Public Storybook](https://apps.iris.trackunit.com/storybook/).
8
+
9
+ For more info and a full guide on Iris App SDK Development, please visit our [Developer Hub](https://developers.trackunit.com/).
10
+
11
+ ## Usage
12
+
13
+ ### Convenience setup functions
14
+
15
+ You can choose between different levels of setup based on your needs:
16
+
17
+ #### Basic mocks (lightweight)
18
+
19
+ Use the `setupBasicMocks` function to set up only essential mocks without external library dependencies:
20
+
21
+ ```javascript
22
+ // In your jest setup file (e.g., jest.setup.js)
23
+ import { setupBasicMocks } from '@trackunit/react-test-setup';
24
+
25
+ setupBasicMocks();
26
+ ```
27
+
28
+ This sets up Canvas, IntersectionObserver, MatchMedia, ResizeObserver, timers, and Web Streams mocks - perfect for most basic React testing needs.
29
+
30
+ #### Default mocks (recommended)
31
+
32
+ Use the `setupDefaultMocks` function to set up a balanced set of mocks that work for most React applications:
33
+
34
+ ```javascript
35
+ // In your jest setup file (e.g., jest.setup.js)
36
+ import { setupDefaultMocks } from '@trackunit/react-test-setup';
37
+
38
+ setupDefaultMocks();
39
+ ```
40
+
41
+ This includes everything in `setupBasicMocks` plus React Testing Library and translations mocks - ideal for most React applications using i18n.
42
+
43
+ #### All mocks (comprehensive)
44
+
45
+ Use the `setupAllMocks` function to set up all available mocks in one call:
46
+
47
+ ```javascript
48
+ // In your jest setup file (e.g., jest.setup.js)
49
+ import { setupAllMocks } from '@trackunit/react-test-setup';
50
+
51
+ setupAllMocks();
52
+ ```
53
+
54
+ This includes everything in `setupDefaultMocks` plus mocks for Google Maps, React Helmet, React Virtualized, and TanStack Virtual.
55
+
56
+ ### Individual setup functions
57
+
58
+ If you need more control, you can use the individual setup functions:
59
+
60
+ ```javascript
61
+ // In your jest setup file
62
+ import {
63
+ setupCanvasMock,
64
+ setupFailOnConsole,
65
+ setupGoogleMaps,
66
+ // ... other setup functions as needed
67
+ } from '@trackunit/react-test-setup';
68
+
69
+ // Set up only what you need
70
+ setupCanvasMock();
71
+ setupFailOnConsole();
72
+ // ... etc.
73
+ ```
74
+
75
+ All setup functions are thoroughly documented with JSDoc comments that explain their purpose and usage.
76
+
77
+ ## Development
78
+
79
+ At this point this library is only developed by Trackunit Employees.
80
+ For development related information see the [development readme](https://github.com/Trackunit/manager/blob/master/libs/react/components/DEVELOPMENT.md).
81
+
82
+ ## Trackunit
83
+
84
+ This package was developed by Trackunit ApS.
85
+ Trackunit is the leading SaaS-based IoT solution for the construction industry, offering an ecosystem of hardware, fleet management software & telematics.
86
+
87
+ ![The Trackunit logo](https://trackunit.com/wp-content/uploads/2022/03/top-logo.svg)
package/index.cjs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";