Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 15, 2025

Simulator testing is difficult without health data. This adds a utility to generate realistic quantity samples for testing.

Changes

  • New function generateQuantityTypeSamples(quantityType, numberOfSamples, options?)

    • Generates samples with realistic value ranges for 60+ health metrics (steps, heart rate, calories, etc.)
    • Distributes samples evenly across time period (defaults to last 30 days)
    • Returns boolean indicating success
  • Options interface with fromDate and toDate for custom date ranges

  • Exported from both iOS and cross-platform entry points

Usage

import { generateQuantityTypeSamples } from '@kingstinct/react-native-healthkit'

// Generate 30 days of step data
await generateQuantityTypeSamples('HKQuantityTypeIdentifierStepCount', 30)

// Custom date range
await generateQuantityTypeSamples(
  'HKQuantityTypeIdentifierHeartRate',
  7,
  { fromDate: new Date('2024-01-01'), toDate: new Date('2024-01-07') }
)

Value ranges are predefined per quantity type (e.g., heart rate: 60-100 bpm, steps: 1000-15000).

Original prompt

This section details on the original issue you should resolve

<issue_title>Health data generation</issue_title>
<issue_description>Thanks for the nice modern lib in TypeScript!

How do you handle testing on the simulator, given that it has no health data? Would it make sense to have an ability to generate test data?</issue_description>

<agent_instructions>Add a function to add quantitySamples with realistic inputs, along these lines

type Options = { fromDate, toDate } // default to last 30 days, and spread out the generation of data over this time period
generateQuantityTypeSamples(quantityType, numberOfSamples, options?: Options)
```</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@robertherber</author><body>
That's a great idea!

I don't have time to look at it right now - but would be more than happy to merge a pull request :)</body></comment_new>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 15, 2025
@changeset-bot
Copy link

changeset-bot bot commented Nov 15, 2025

⚠️ No Changeset found

Latest commit: d96d927

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI changed the title [WIP] Add function to generate health data samples Add generateQuantityTypeSamples utility for simulator test data Nov 15, 2025
Copilot finished work on behalf of robertherber November 15, 2025 01:53
Copilot AI requested a review from robertherber November 15, 2025 01:53
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 15, 2025

Open in StackBlitz

npm i https://pkg.pr.new/kingstinct/react-native-healthkit/@kingstinct/react-native-healthkit@263

commit: d96d927

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Health data generation

2 participants