Skip to content

test: cover home expansion in path arrays - #1077

Merged
motdotla merged 1 commit into
motdotla:masterfrom
renanmpimentel:test/home-path-array
Oct 22, 2026
Merged

motdotla merged 1 commit into
motdotla:masterfrom
renanmpimentel:test/home-path-array

Conversation

@renanmpimentel

@renanmpimentel renanmpimentel commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Why this test matters

A refactor could skip home-directory expansion only when path is an array, causing config() to look for a literal ~/.env and miss the intended configuration file. The new assertion catches that branch-specific regression.

Supertest audit method

I used the Supertest test-audit skill to probe whether the existing suite would catch a plausible violation of this contract. The regression was applied only in an isolated worktree. The regression proof records three executed states: the existing tests pass with that regression, the new assertion fails against the same regression, and the new test passes with the original production code restored. The published diff adds tests only.

Change and verification

Summary

Add a test for ~ expansion when config({ path }) receives an array. The existing test covers the string form, while the array form follows a separate branch in configDotenv.

Regression proof

In an isolated worktree, I replaced optionPaths.push(_resolveHome(filepath)) with optionPaths.push(filepath). The existing tests/test-config.js still passed (79/79). With this test added, the same regression fails because fs.readFileSync receives ~/.env instead of the path under os.homedir(). With production code restored, the full suite passes.

Verification

  • npm test — 1,415 passed, 1 skipped (includes build, StandardJS lint, and TypeScript declaration checks)
  • git diff --check — passed

The permanent change is limited to tests/test-config.js.

Repository guidance

CONTRIBUTING.md calls for TAP tests and StandardJS lint; npm test includes both. No PR template was present in the audited checkout.

@motdotla

Copy link
Copy Markdown
Owner

ok this is some additional coverage. thanks.

@motdotla
motdotla merged commit c40119a into motdotla:master Oct 22, 2026
4 of 8 checks passed
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