@harnessio/ff-react-client-sdk
Advanced tools
Comparing version 1.3.0 to 1.4.0-rc1
{ | ||
"name": "@harnessio/ff-react-client-sdk", | ||
"version": "1.3.0", | ||
"version": "1.4.0-rc1", | ||
"author": "Harness", | ||
@@ -24,3 +24,3 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@harnessio/ff-javascript-client-sdk": "^1.10.0", | ||
"@harnessio/ff-javascript-client-sdk": "^1.12.0", | ||
"lodash.omit": "^4.5.0" | ||
@@ -27,0 +27,0 @@ }, |
@@ -12,3 +12,3 @@ # React.js Client SDK For Harness Feature Flags | ||
This sample doesn't include configuration options, for in depth steps and configuring the SDK, see | ||
the [React Client SDK Reference](https://docs.harness.io/article/ptyhvcixyg-react-client-sdk-guide). | ||
the [React Client SDK Reference](https://developer.harness.io/docs/feature-flags/ff-sdks/client-sdks/react-client). | ||
@@ -24,5 +24,5 @@ ## Requirements | ||
- [Created a Feature Flag on the Harness Platform](https://docs.harness.io/article/1j7pdkqh7j-create-a-feature-flag) | ||
- [Created a Feature Flag on the Harness Platform](https://developer.harness.io/docs/feature-flags/ff-creating-flag/create-a-feature-flag/) | ||
called `harnessappdemodarkmode` | ||
- [Created a client SDK key](https://docs.harness.io/article/1j7pdkqh7j-create-a-feature-flag#step_3_create_an_sdk_key) | ||
- [Created a client SDK key](https://developer.harness.io/docs/feature-flags/ff-creating-flag/create-a-feature-flag/) | ||
and made a copy of it | ||
@@ -351,6 +351,30 @@ | ||
## Testing with Jest | ||
When running tests with Jest, you may want to mock the SDK to avoid making network requests. You can do this by using | ||
the included `TestWrapper` component. This component accepts a listing of flags and their values, and will mock the SDK | ||
to return those values. In the example below, we use Testing Library to render the component `<MyComponent />` that | ||
internally uses the `useFeatureFlag` hook. | ||
```typescript jsx | ||
import { render, screen } from '@testing-library/react' | ||
import { TestWrapper } from '@harnessio/ff-react-client-sdk/test-utils' | ||
// ... | ||
test('it should render the flag value', () => { | ||
render( | ||
<TestWrapper flags={{ flag1: 'value1', flag2: 'value2' }}> | ||
<MyComponent /> | ||
</TestWrapper> | ||
) | ||
expect(screen.getByText('value1')).toBeInTheDocument() | ||
}) | ||
``` | ||
## Additional Reading | ||
For further examples and config options, see | ||
the [React.js Client SDK Reference](https://docs.harness.io/article/ptyhvcixyg-react-client-sdk-guide) | ||
the [React.js Client SDK Reference](https://developer.harness.io/docs/feature-flags/ff-sdks/client-sdks/react-client) | ||
For more information about Feature Flags, see | ||
@@ -357,0 +381,0 @@ our [Feature Flags documentation](https://docs.harness.io/article/0a2u2ppp8s-getting-started-with-feature-flags). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44369
391
1