Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.9.0](https://github.com/americanexpress/fetchye/compare/v1.8.0...v1.9.0) (2026-03-30)


### Bug Fixes

* **isLoading:** added catch for post render edge case ([6e30af6](https://github.com/americanexpress/fetchye/commit/6e30af6af26e1b872911653b7b476605b7ac307d))


### Features

* **fetchye-one-app:** add streaming support ([#110](https://github.com/americanexpress/fetchye/issues/110)) ([53185ea](https://github.com/americanexpress/fetchye/commit/53185ea772e43cba0aaa86b2b337267449c97246)), closes [#111](https://github.com/americanexpress/fetchye/issues/111)





# [1.8.0](https://github.com/americanexpress/fetchye/compare/v1.7.0...v1.8.0) (2025-11-26)


Expand Down
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,69 @@ const BookList = ({ genre }) => {
};
```

### Unit Testing and Mocking

Fetchye can be tested with Jest and React Testing Library by rendering a small
component that uses `useFetchye` and asserting the hook state over time.

```jsx
import React from 'react';
import { render, waitFor } from '@testing-library/react';
import { FetchyeProvider, SimpleCache, useFetchye } from 'fetchye';

const customFetchClient = jest.fn(async () => ({
ok: true,
status: 200,
text: async () => JSON.stringify({
name: 'Ada Lovelace',
}),
}));

const customFetcher = async (fetchClient, key, options) => {
const response = await fetchClient(key, options);
return {
payload: {
ok: response.ok,
status: response.status,
body: JSON.parse(await response.text()),
},
error: undefined,
};
};

it('fetches profile data with a mocked custom fetcher', async () => {
let result;

render(
<FetchyeProvider cache={SimpleCache()} fetchClient={customFetchClient}>
{React.createElement(() => {
result = useFetchye('http://example.com/api/profile', {}, customFetcher);
return null;
})}
</FetchyeProvider>
);

await waitFor(() => expect(result.isLoading).toBe(false));
expect(customFetchClient).toHaveBeenCalledWith(
'http://example.com/api/profile',
{}
);
expect(result.data.body.name).toBe('Ada Lovelace');
});
```

If you are not injecting a custom fetcher, mock `global.fetch` directly:

```jsx
global.fetch = jest.fn(async () => ({
ok: true,
status: 200,
text: async () => JSON.stringify({
name: 'Ada Lovelace',
}),
}));
```

### Deferred execution

When you need to delay execution of a `useFetchye` call, you may use
Expand Down Expand Up @@ -806,6 +869,7 @@ const ParentComponent = ({ children }) => (
- [One App Install](#one-app-install)
- [🤹‍ Usage](#-usage)
- [Real-World Example](#real-world-example)
- [Unit Testing and Mocking](#unit-testing-and-mocking)
- [Deferred execution](#deferred-execution)
- [Abort Inflight Requests](#abort-inflight-requests)
- [Sequential API Execution](#sequential-api-execution)
Expand Down
8 changes: 2 additions & 6 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*"
],
"command": {
"version": {
"conventionalCommits": true,
"allowBranch": "chore/release-*"
}
},
"version": "1.8.0"
}
"version": "1.9.0"
}
8 changes: 8 additions & 0 deletions packages/fetchye-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.9.0](https://github.com/americanexpress/fetchye/compare/v1.8.0...v1.9.0) (2026-03-30)

**Note:** Version bump only for package fetchye-core





# [1.8.0](https://github.com/americanexpress/fetchye/compare/v1.7.0...v1.8.0) (2025-11-26)

**Note:** Version bump only for package fetchye-core
Expand Down
2 changes: 1 addition & 1 deletion packages/fetchye-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fetchye-core",
"version": "1.8.0",
"version": "1.9.0",
"description": "Core components of the Fetchye library",
"license": "Apache-2.0",
"main": "lib/index.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/fetchye-immutable-cache/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.9.0](https://github.com/americanexpress/fetchye/compare/v1.8.0...v1.9.0) (2026-03-30)

**Note:** Version bump only for package fetchye-immutable-cache





# [1.8.0](https://github.com/americanexpress/fetchye/compare/v1.7.0...v1.8.0) (2025-11-26)

**Note:** Version bump only for package fetchye-immutable-cache
Expand Down
4 changes: 2 additions & 2 deletions packages/fetchye-immutable-cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fetchye-immutable-cache",
"version": "1.8.0",
"version": "1.9.0",
"description": "Immutable cache library to use with fetchye.",
"license": "Apache-2.0",
"main": "lib/index.js",
Expand Down Expand Up @@ -42,7 +42,7 @@
"@babel/core": "7.11.6",
"babel-preset-amex": "^3.4.1",
"cross-env": "^7.0.2",
"fetchye-test-utils": "^1.8.0",
"fetchye-test-utils": "^1.9.0",
"redux": "^4.0.5",
"rimraf": "^3.0.2"
},
Expand Down
11 changes: 11 additions & 0 deletions packages/fetchye-one-app/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.9.0](https://github.com/americanexpress/fetchye/compare/v1.8.0...v1.9.0) (2026-03-30)


### Features

* **fetchye-one-app:** add streaming support ([#110](https://github.com/americanexpress/fetchye/issues/110)) ([53185ea](https://github.com/americanexpress/fetchye/commit/53185ea772e43cba0aaa86b2b337267449c97246)), closes [#111](https://github.com/americanexpress/fetchye/issues/111)





# [1.8.0](https://github.com/americanexpress/fetchye/compare/v1.7.0...v1.8.0) (2025-11-26)

**Note:** Version bump only for package fetchye-one-app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ const streamActionSpy = jest.spyOn(actions, 'stream');
const mockDispatch = jest.fn();

describe('streamFetchye', () => {
const originalWindow = global.window;

beforeEach(() => {
jest.clearAllMocks();
Object.defineProperty(global, 'window', {
value: undefined,
configurable: true,
writable: true,
});
});

afterEach(() => {
global.window = originalWindow;
});

it('should return a one-app-thunk that dispatches an action resolving to the passed in thunk', async () => {
expect.assertions(2);

Expand Down Expand Up @@ -63,4 +78,21 @@ describe('streamFetchye', () => {
);
expect(fetchyeThunk).toHaveBeenCalledWith(...fetchyeParams.slice(1));
});

it('should not dispatch the stream action on the client', async () => {
expect.assertions(1);

global.window = originalWindow;

const fetchyeThunk = jest.fn();
fetchyeThunk.mockResolvedValue(Symbol('fetchRequest'));

const fetchyeParams = [fetchyeThunk, Symbol('fetchyeArgs - key'), Symbol('fetchyeArgs - options'), Symbol('fetchyeArgs - fetcher')];
const streamFetchyeThunk = streamFetchye(...fetchyeParams);
const thunkParams = [mockDispatch, Symbol('getState'), Symbol('fetchClient')];
await streamFetchyeThunk(
fetchyeThunk, thunkParams[0], thunkParams[1], { fetchClient: thunkParams[2] }
);
expect(streamActionSpy).not.toHaveBeenCalled();
});
});
10 changes: 5 additions & 5 deletions packages/fetchye-one-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fetchye-one-app",
"version": "1.8.0",
"version": "1.9.0",
"description": "Collection of helpers to aid fetchye integration with One App",
"license": "Apache-2.0",
"main": "lib/index.js",
Expand Down Expand Up @@ -40,9 +40,9 @@
],
"dependencies": {
"@babel/runtime": "^7.11.2",
"fetchye-immutable-cache": "^1.8.0",
"fetchye-redux-provider": "^1.8.0",
"fetchye-test-utils": "^1.8.0",
"fetchye-immutable-cache": "^1.9.0",
"fetchye-redux-provider": "^1.9.0",
"fetchye-test-utils": "^1.9.0",
"invariant": "^2.2.4",
"prop-types": "^15.7.2"
},
Expand All @@ -58,7 +58,7 @@
"@testing-library/react-hooks": "^3.4.2",
"babel-preset-amex": "^3.4.1",
"cross-env": "^7.0.2",
"fetchye-core": "^1.8.0",
"fetchye-core": "^1.9.0",
"immutable": "^4.0.0-rc.12",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
20 changes: 11 additions & 9 deletions packages/fetchye-one-app/src/streaming/streamFetchye.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ export const streamFetchye = (thunk, key, opts = {}, fetcher = undefined) => asy
const { hash: computedKey } = computeKey(key, opts);
const promise = dispatch(thunk(key, opts, fetcher));

dispatch(
stream([
{
key: computedKey,
domain: STREAM_DOMAIN,
promise,
},
])
);
if (!global.window) {
dispatch(
stream([
{
key: computedKey,
domain: STREAM_DOMAIN,
promise,
},
])
);
}

return promise;
};
8 changes: 8 additions & 0 deletions packages/fetchye-redux-provider/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.9.0](https://github.com/americanexpress/fetchye/compare/v1.8.0...v1.9.0) (2026-03-30)

**Note:** Version bump only for package fetchye-redux-provider





# [1.8.0](https://github.com/americanexpress/fetchye/compare/v1.7.0...v1.8.0) (2025-11-26)


Expand Down
4 changes: 2 additions & 2 deletions packages/fetchye-redux-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fetchye-redux-provider",
"version": "1.8.0",
"version": "1.9.0",
"description": "Redux provider for fetchye.",
"license": "Apache-2.0",
"main": "lib/index.js",
Expand Down Expand Up @@ -43,7 +43,7 @@
"@testing-library/react": "^11.0.4",
"babel-preset-amex": "^3.4.1",
"cross-env": "^7.0.2",
"fetchye": "^1.8.0",
"fetchye": "^1.9.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rimraf": "^3.0.2"
Expand Down
8 changes: 8 additions & 0 deletions packages/fetchye-test-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.9.0](https://github.com/americanexpress/fetchye/compare/v1.8.0...v1.9.0) (2026-03-30)

**Note:** Version bump only for package fetchye-test-utils





# [1.8.0](https://github.com/americanexpress/fetchye/compare/v1.7.0...v1.8.0) (2025-11-26)

**Note:** Version bump only for package fetchye-test-utils
Expand Down
2 changes: 1 addition & 1 deletion packages/fetchye-test-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fetchye-test-utils",
"version": "1.8.0",
"version": "1.9.0",
"description": "Core components of the Fetchye library",
"license": "Apache-2.0",
"main": "lib/index.js",
Expand Down
16 changes: 16 additions & 0 deletions packages/fetchye/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.9.0](https://github.com/americanexpress/fetchye/compare/v1.8.0...v1.9.0) (2026-03-30)


### Bug Fixes

* **isLoading:** added catch for post render edge case ([6e30af6](https://github.com/americanexpress/fetchye/commit/6e30af6af26e1b872911653b7b476605b7ac307d))


### Features

* **fetchye-one-app:** add streaming support ([#110](https://github.com/americanexpress/fetchye/issues/110)) ([53185ea](https://github.com/americanexpress/fetchye/commit/53185ea772e43cba0aaa86b2b337267449c97246)), closes [#111](https://github.com/americanexpress/fetchye/issues/111)





# [1.8.0](https://github.com/americanexpress/fetchye/compare/v1.7.0...v1.8.0) (2025-11-26)

### Features
Expand Down
6 changes: 3 additions & 3 deletions packages/fetchye/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fetchye",
"version": "1.8.0",
"version": "1.9.0",
"description": "If you know how to use Fetch, you know how to use Fetchye [fetch-yae]. Simple React Hooks, Centralized Cache, Infinitely Extensible.",
"license": "Apache-2.0",
"main": "lib/index.js",
Expand Down Expand Up @@ -53,7 +53,7 @@
],
"dependencies": {
"@babel/runtime": "^7.11.2",
"fetchye-core": "^1.8.0",
"fetchye-core": "^1.9.0",
"object-hash": "^2.0.3",
"prop-types": "^15.7.2"
},
Expand All @@ -67,7 +67,7 @@
"@testing-library/react": "^11.0.4",
"babel-preset-amex": "^3.4.1",
"cross-env": "^7.0.2",
"fetchye-test-utils": "^1.8.0",
"fetchye-test-utils": "^1.9.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.1",
Expand Down
Loading