Skip to content

Commit

Permalink
fix: re-render w/ useWhenProviderReady, add tests (#901)
Browse files Browse the repository at this point in the history
This PR:

- brings react-sdk test coverage from 0% to ~95%
  - adds DOM-based testing (tests based on asserting DOM entity states)
    - tests for query-style, basic, and detailed evaluation APIs
- tests for suspense functionality and re-rendering on context change
  - tests for some util functions and hooks
  - `renderHook` tests for non suspending hooks
- fixes a bug where `useWhenProviderReady` didn't cause re-render after
the provider is ready if suspense wasn't used (leading to an out-of-date
return value for provider readiness)


![image](https://github.com/open-feature/js-sdk/assets/25272906/e8ee420f-0167-4048-94e3-53176bd883b9)

---------

Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert authored Apr 11, 2024
1 parent 240a461 commit 0f2094e
Show file tree
Hide file tree
Showing 8 changed files with 1,095 additions and 9 deletions.
18 changes: 18 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,24 @@ export default {
],
},
},
{
displayName: 'react',
testEnvironment: 'jsdom',
preset: 'ts-jest',
testMatch: ['<rootDir>/packages/react/test/**/*.spec.ts*'],
moduleNameMapper: {
'@openfeature/core': '<rootDir>/packages/shared/src',
'@openfeature/web-sdk': '<rootDir>/packages/client/src',
},
transform: {
'^.+\\.tsx$': [
'ts-jest',
{
tsconfig: '<rootDir>/packages/react/test/tsconfig.json',
},
],
},
},
],

// Use this configuration option to add custom reporters to Jest
Expand Down
Loading

0 comments on commit 0f2094e

Please sign in to comment.