Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 14, 2025

  • Add comprehensive tests for utils.R and improve coverage for low-coverage files
  • Fix test failures caused by missing sjlabelled package in nice_modindices function
  • Update documentation and fix styling issues
  • All tests now pass (89 PASS, 0 FAIL, 40 SKIP due to optional packages)

Fixed Issues

nice_modindices Function Fix

  • Problem: Tests were failing when sjlabelled package was not available
  • Solution: Added skip_if_not_installed("sjlabelled") checks to relevant tests while keeping the original function behavior
  • Result: Function maintains original functionality while tests gracefully skip when optional packages aren't available

Changes Made

  • Added skip checks to three tests in tests/testthat/test-nice_modindices.R:
    • nice_modindices without labels
    • nice_modindices with sort = FALSE
    • nice_modindices with additional lavaan parameters
  • Kept R/nice_modindices.R in its original state with insight::check_if_installed("sjlabelled")
  • Updated documentation using devtools::document()
  • All tests now pass: 89 PASS, 0 FAIL, 40 SKIP

The function properly requires sjlabelled when labels need to be extracted automatically, while tests skip gracefully when the package is not available. This maintains the intended behavior while preventing test failures in environments without optional packages.

Fixes the test errors mentioned in PR comments.


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

Copilot AI changed the title [WIP] Add tests for utils.R (get_dep_version()) Add comprehensive tests for utils.R and improve coverage for low-coverage files Sep 14, 2025
Copilot AI requested a review from rempsyc September 14, 2025 19:29
Copilot finished work on behalf of rempsyc September 14, 2025 19:29
@rempsyc rempsyc marked this pull request as ready for review September 14, 2025 23:24
@rempsyc
Copy link
Owner

rempsyc commented Sep 14, 2025

@copilot thanks, I see the following errors:

══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test-nice_modindices.R:71:3'): nice_modindices without labels ───────
Error: Error: Package `sjlabelled` required for this function to work.
  Please install it by running `install.packages("sjlabelled")`.

And make sure to redocument, fix lints, style, etc.

Copy link
Contributor Author

Copilot AI commented Sep 14, 2025

@copilot thanks, I see the following errors:

...

Fixed the test failures by making the sjlabelled dependency conditional in the nice_modindices function. The function now uses requireNamespace("sjlabelled", quietly = TRUE) instead of insight::check_if_installed(), allowing it to work gracefully when the package is not available. All tests now pass (95 PASS, 0 FAIL). Also updated documentation and applied proper styling. Commit: f61e308

Copilot finished work on behalf of rempsyc September 14, 2025 23:51
labels <- sjlabelled::get_label(dat)
if (all(labels == "")) {
labels <- NULL
if (requireNamespace("sjlabelled", quietly = TRUE)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot In fact, we don't want to run it conditionally here, because we always want to extract the labels this way when it is not provided manually. Instead, what we want to do, is to add a skip check in the corresponding test file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. I've reverted the nice_modindices function to its original state (keeping insight::check_if_installed("sjlabelled")) and instead added skip_if_not_installed("sjlabelled") checks to the three failing tests. This preserves the intended behavior of always extracting labels when not provided manually, while making tests skip gracefully when the package isn't available. All tests now pass: 89 PASS, 0 FAIL, 40 SKIP. Commit: 7cbf067

Copilot AI requested a review from rempsyc September 15, 2025 00:07
Copilot finished work on behalf of rempsyc September 15, 2025 00:07
@rempsyc rempsyc merged commit fc699d1 into main Sep 15, 2025
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