test: expand cosmiconfig coverage before upgrade#655
Merged
Conversation
There was a problem hiding this comment.
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
--configtests for relative/absolute paths and resolving a config package fromnode_modules; fix CLI resolution to avoid throwing on failed resolve. - Document
result.config.filePathand adjust TypeScript types to reflect it, plus allow committed JS fixtures via.gitignoreexception.
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.
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
force-pushed
the
test/cosmiconfig-coverage
branch
from
July 2, 2026 02:31
ed7a240 to
f3570b1
Compare
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>
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
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>
4 tasks
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>
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.webfontrcjson/yaml/js,webfont.config.js,package.json, walk-up, no config)--configtests (relative path, absolute path,node_modulespackage)--configresolution usingresolveFrom.silent(bug:resolveFromthrew before the cwd fallback)result.config.filePathin the README and align TypeScript types (filePathis output metadata, not input)src/fixtures/**via.gitignoreexceptionTest plan
npm test— 65 tests passing locallyNotes
No breaking changes. Prepares safe migration to cosmiconfig v7 (#573) and later latest.
Made with Cursor