Skip to content

Fix flaky/fragile tests: add skip guards for optional dependencies and widen timestamp tolerance#206

Merged
mitokic merged 2 commits intomitokic-02202026-unit-testsfrom
copilot/sub-pr-205
Feb 21, 2026
Merged

Fix flaky/fragile tests: add skip guards for optional dependencies and widen timestamp tolerance#206
mitokic merged 2 commits intomitokic-02202026-unit-testsfrom
copilot/sub-pr-205

Conversation

Copy link
Contributor

Copilot AI commented Feb 21, 2026

Several unit tests introduced in the previous commit were brittle: they'd fail in environments missing Suggests-only packages (jsonlite, corrr, ranger, vip), on single-core machines, or on slow CI runners.

Changes

  • test-agent_helpers.R — Added skip_if_not_installed("jsonlite") to all extract_json_object() tests
  • test-feature_selection.R — Added skip_if_not_installed("corrr") to all target_corr_fn tests; added skip_if_not_installed("ranger") + skip_if_not_installed("vip") to vip_rf_fn test
  • test-parallel_util.R — Added skip_if(parallel::detectCores() <= 1) to the local_machine cluster test to prevent makeCluster(0) errors on single-core runners
  • test-utility.R — Re-created (was accidentally deleted); widened get_timestamp() timing tolerance from 5s → 60s to reduce flakiness on loaded CI
# Example pattern applied throughout
test_that("extract_json_object parses simple JSON", {
  skip_if_not_installed("jsonlite")
  ...
})

test_that("par_start with local_machine creates cluster", {
  skip_if(parallel::detectCores() <= 1, "Requires more than one core")
  ...
})

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@mitokic mitokic marked this pull request as ready for review February 21, 2026 01:08
Co-authored-by: mitokic <16709433+mitokic@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests for hyperparameter grid improvements Fix flaky/fragile tests: add skip guards for optional dependencies and widen timestamp tolerance Feb 21, 2026
Copilot AI requested a review from mitokic February 21, 2026 01:11
@mitokic mitokic merged commit 47c722b into mitokic-02202026-unit-tests Feb 21, 2026
1 check passed
@mitokic mitokic deleted the copilot/sub-pr-205 branch February 21, 2026 01:12
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.

2 participants