Registry / testing / yargs-test-extends

yargs-test-extends

JSON →
library1.0.1jsnpmunverified

The `yargs-test-extends` package is a specialized internal fixture designed for unit testing the `.config()` and `extends` functionality within the `yargs` command-line argument parsing library. It is not intended for general-purpose use in consumer applications, but rather serves as a static configuration source to verify `yargs`'s dynamic configuration loading capabilities. This package currently maintains version `1.0.1`. Its primary role is to demonstrate and verify that `yargs` can load configuration from an external Node.js module by inspecting its `main` entry point, which points to a static `index.json` file containing predefined configuration values. This mechanism tests `yargs`'s ability to extend configuration dynamically from installed packages rather than solely from local JSON files, ensuring robust configuration management within the `yargs` ecosystem.

npm install yargs-test-extends
INSTALL
IMPORT
SIG · YARGS-TEST-EXTENDS
Y
yargs-test-extends
testingjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

yargs-test-extends (as config extension string)
yargs().config({ extends: 'yargs-test-extends' })
This package is designed as a configuration fixture for `yargs`. It is referenced by its package name as a string to `yargs`'s `.config()` method, which then internally resolves its `main` entry point (`index.json`) for configuration. This is the primary intended method of 'using' this package.
config (CommonJS direct require)
const config = require('yargs-test-extends');
Direct CommonJS `require()` of this package will load the raw `index.json` content as a JavaScript object. This is typically not the intended use when interacting with `yargs`'s `extends` feature, but useful for inspecting the raw configuration fixture programmatically.
config (ESM direct import)
import config from 'yargs-test-extends';
import { c } from 'yargs-test-extends';
In an ESM environment, importing this package directly will similarly yield the `index.json` content as the default export. Note that `yargs`'s `extends` mechanism handles module resolution differently from direct module imports, and named imports like `{ c }` will not work as the JSON is a default export.

Demonstrates `yargs` loading configuration from an external Node.js module specified by `extends`.

const yargs = require('yargs'); const assert = require('assert'); // This example demonstrates how yargs loads configuration // from the 'yargs-test-extends' module via its 'extends' mechanism. // The 'yargs-test-extends' package's package.json specifies 'index.json' as its main. // The index.json contains { "c": 201 }. // The initial config sets 'a' to 2. const argv = yargs() .config({ a: 2, extends: 'yargs-test-extends' // Yargs resolves this module's main file }) .argv; // Verify that the initial config 'a' is preserved. assert.strictEqual(argv.a, 2, 'Value for `a` should be 2 from direct config.'); // Verify that 'c' is loaded from the extended module. assert.strictEqual(argv.c, 201, 'Value for `c` should be 201 from extended module.'); console.log('Yargs successfully extended configuration from yargs-test-extends.'); console.log('Parsed argv:', argv);
Debug
Known issues
gotchaThis package (`yargs-test-extends`) is a test fixture for the 'yargs' library and is not intended for general use in consumer applications. It serves a specific role in `yargs`'s internal testing suite.
fix
Avoid using 'yargs-test-extends' in production code. For dynamic configuration in your own `yargs` applications, create your own module that exports a configuration object or points to a custom JSON file.
affects: >=1.0.0
gotchaAttempting to import or require 'yargs-test-extends' directly will return the raw JSON object defined in its `index.json` file, not a processed `yargs` configuration object or functionality. Its `package.json` specifies `main: 'index.json'`.
fix
If you need to inspect the raw configuration, direct import/require is functional. However, if you intend for `yargs` to interpret it as an extension, you must use `yargs().config({ extends: 'yargs-test-extends' })`.
affects: >=1.0.0
Errors
Common errors & fixes
Unexpected object received when requiring 'yargs-test-extends' directly.
The package's `main` entry points to `index.json`, causing `require()` or `import` to return a plain JavaScript object (parsed JSON), not a module exporting functions or a default configuration object interpreted by `yargs`.
fix
Understand that direct `require('yargs-test-extends')` or `import config from 'yargs-test-extends'` provides the raw JSON content. For `yargs` to process it as an extension, use `yargs().config({ extends: 'yargs-test-extends' })`.
Module not found: Can't resolve 'yargs-test-extends'
The `yargs-test-extends` package has not been installed, but `yargs`'s `.config({ extends: 'yargs-test-extends' })` is attempting to resolve it.
fix
Ensure `yargs-test-extends` is listed in your project's `dependencies` or `devDependencies` (if used only for testing) and installed via `npm install yargs-test-extends` or `yarn add yargs-test-extends`.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
1
Resources
yargs-test-extends — npm install yargs-test-extends · libregistry