Skip to content

test: expand cosmiconfig coverage before upgrade#655

Merged
jimmyandrade merged 5 commits into
masterfrom
test/cosmiconfig-coverage
Jul 2, 2026
Merged

test: expand cosmiconfig coverage before upgrade#655
jimmyandrade merged 5 commits into
masterfrom
test/cosmiconfig-coverage

Conversation

@jimmyandrade

@jimmyandrade jimmyandrade commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add fixtures and tests for all cosmiconfig v5 discovery paths (.webfontrc json/yaml/js, webfont.config.js, package.json, walk-up, no config)
  • Add CLI --config tests (relative path, absolute path, node_modules package)
  • Fix relative --config resolution using resolveFrom.silent (bug: resolveFrom threw before the cwd fallback)
  • Document result.config.filePath in the README and align TypeScript types (filePath is output metadata, not input)
  • Allow committed JS under src/fixtures/** via .gitignore exception

Test plan

  • npm test — 65 tests passing locally
  • CI green on Linux (Biome + Jest)

Notes

No breaking changes. Prepares safe migration to cosmiconfig v7 (#573) and later latest.

Made with Cursor

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR expands configuration-discovery and CLI --config test coverage ahead of a planned cosmiconfig upgrade, adds documentation for result.config.filePath, and fixes a CLI relative --config resolution edge case by using resolveFrom.silent.

Changes:

  • Add comprehensive cosmiconfig discovery tests and fixtures (rc formats, webfont.config.js, package.json, walk-up, and no-config behavior).
  • Add CLI --config tests for relative/absolute paths and resolving a config package from node_modules; fix CLI resolution to avoid throwing on failed resolve.
  • Document result.config.filePath and adjust TypeScript types to reflect it, plus allow committed JS fixtures via .gitignore exception.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types/OptionsBase.ts Adds filePath to the shared options type.
src/types/InitialOptions.ts Removes redundant filePath declaration from InitialOptions.
src/standalone/index.test.ts Asserts result.config.filePath for explicit configFile usage.
src/standalone/cosmiconfig.test.ts Adds new discovery/load coverage for cosmiconfig search paths and filePath output.
src/cli/index.ts Switches to resolveFrom.silent for safer --config resolution.
src/cli/index.test.ts Adds --config coverage (relative/absolute/module) and sets up a fixture package in node_modules.
src/fixtures/configs/.webfontrc-cli.json Adds CLI config fixture.
src/fixtures/config-package/package.json Adds a fixture package for --config <package> tests.
src/fixtures/config-package/index.js Exports fixture config from the package entrypoint.
src/fixtures/config-discovery/json/.webfontrc.json Adds discovery fixture for JSON rc.
src/fixtures/config-discovery/yaml/.webfontrc.yaml Adds discovery fixture for YAML rc.
src/fixtures/config-discovery/js-rc/.webfontrc.js Adds discovery fixture for JS rc.
src/fixtures/config-discovery/js-config/webfont.config.js Adds discovery fixture for webfont.config.js.
src/fixtures/config-discovery/package-json/package.json Adds discovery fixture for package.json webfont key.
src/fixtures/config-discovery/walkup/.webfontrc.json Adds discovery fixture for walk-up behavior.
README.md Documents result.config.filePath and adds a Result section.
.gitignore Allows committed JS under src/fixtures/** via negation rule.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/types/OptionsBase.ts
Comment thread src/types/InitialOptions.ts
Comment thread src/standalone/cosmiconfig.test.ts
jimmyandrade and others added 3 commits July 1, 2026 23:28
Add search/load fixtures and tests for all cosmiconfig discovery paths,
cover CLI --config (relative, absolute, and node_modules), fix relative
--config resolution with resolveFrom.silent, and document result.config.filePath.

Co-authored-by: Cursor <cursoragent@cursor.com>
Extend the noCommonJs override to src/fixtures/**/*.js so cosmiconfig
CommonJS config fixtures pass lint in CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
Introduce ResultConfig for result.config, strip filePath from input
options, and clean up runtime fixture directories after cosmiconfig tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jimmyandrade
jimmyandrade force-pushed the test/cosmiconfig-coverage branch from ed7a240 to f3570b1 Compare July 2, 2026 02:31
Document that result.config.filePath is not an input option and update
the cosmiconfig test to assert runtime behavior without @ts-expect-error.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 1 comment.

Comment thread src/cli/index.test.ts Outdated
Replace sync mkdirSync/symlinkSync inside Promise callbacks with
fs/promises in beforeAll/afterAll/beforeEach, and add AGENTS.md
guidance on avoiding uncaught exceptions in Jest hooks.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jimmyandrade
jimmyandrade requested a review from Copilot July 2, 2026 02:49
@jimmyandrade
jimmyandrade merged commit 1e21e16 into master Jul 2, 2026
3 checks passed
@jimmyandrade
jimmyandrade deleted the test/cosmiconfig-coverage branch July 2, 2026 02:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 21 changed files in this pull request and generated no new comments.

jimmyandrade added a commit to pravi/webfont that referenced this pull request Jul 2, 2026
Switch to the named cosmiconfig export, tighten buildConfig typing for
v7 results, and load configFile paths without a redundant search() call.

Rebases the original itgalaxy#573 upgrade onto current master with cosmiconfig
coverage tests from itgalaxy#655.

Closes itgalaxy#572

Co-authored-by: Cursor <cursoragent@cursor.com>
jimmyandrade added a commit that referenced this pull request Jul 2, 2026
Switch to the named cosmiconfig export, tighten buildConfig typing for
v7 results, and load configFile paths without a redundant search() call.

Rebases the original #573 upgrade onto current master with cosmiconfig
coverage tests from #655.

Closes #572

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants