Skip to content

Commit 1810bdc

Browse files
committed
RELEASING: Releasing 2 package(s)
Releases: kosha@1.1.0 @repo/shared@0.0.9
1 parent 60cc3d0 commit 1810bdc

File tree

6 files changed

+57
-19
lines changed

6 files changed

+57
-19
lines changed

.changeset/large-rabbits-strive.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,36 @@ Got an idea for a middleware plugin or improvement? We'd love to collaborate.
238238
239239
---
240240
241+
## 🧪 Testing and Mocking
242+
243+
Kosha exposes setState, allowing you to inject test data directly.
244+
Resettable Test Stores
245+
246+
For advanced test isolation, you can register and reset stores:
247+
248+
```tsx
249+
import { act } from "react-dom/test-utils";
250+
import { afterEach } from "jest";
251+
import { create } from "kosha";
252+
import type { StoreCreator, BaseType } from "kosha";
253+
254+
export const storeResetFns = new Set<() => void>();
255+
256+
// use createTestStore for mocking up store in your test cases
257+
export const createTestStore = <T extends BaseType>(creator: StoreCreator<T>) => {
258+
const useStore = create(creator);
259+
const initial = useStore.getState();
260+
storeResetFns.add(() => useStore.setState(initial!, true));
261+
return useStore;
262+
};
263+
264+
afterEach(() => {
265+
act(() => storeResetFns.forEach(resetFn => resetFn()));
266+
});
267+
```
268+
269+
Use this pattern to reset stores automatically before each test.
270+
241271
## 🧠 Internals & Caveats
242272
243273
### 🔍 Why use `JSON.stringify` for selector comparison?

lib/CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# kosha
22

3+
## 1.1.0
4+
5+
### Minor Changes
6+
7+
- 60cc3d0: Add setState, Enhanced Testability
8+
9+
Highlights:
10+
11+
✅ Exposed useStore.setState() for external updates and testing
12+
13+
✅ Supports both partial and full state updates via replace flag
14+
15+
🧪 Enables mock-friendly store patterns for unit testing
16+
17+
🔄 Adds overload-safe StateSetter type for better DX
18+
19+
📄 Docs updated with usage examples and known limitations
20+
321
## 1.0.6
422

523
### Patch Changes

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "kosha",
33
"author": "Mayank Kumar Chaudhari <https://mayank-chaudhari.vercel.app>",
44
"private": false,
5-
"version": "1.0.6",
5+
"version": "1.1.0",
66
"description": "A modern, lightweight, fast, and powerful global state management library for modern React.js projects. ",
77
"license": "MPL-2.0",
88
"main": "./dist/index.js",

packages/shared/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @repo/shared
22

3+
## 0.0.9
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [60cc3d0]
8+
- kosha@1.1.0
9+
310
## 0.0.8
411

512
### Patch Changes

packages/shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@repo/shared",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"private": true,
55
"sideEffects": false,
66
"main": "./dist/index.js",

0 commit comments

Comments
 (0)