{"id":18084,"library":"yargs-test-extends","title":"Yargs Configuration Extends Test Module","description":"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.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install yargs-test-extends","lang":"bash","label":"npm"},{"cmd":"yarn add yargs-test-extends","lang":"bash","label":"yarn"},{"cmd":"pnpm add yargs-test-extends","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","symbol":"yargs-test-extends (as config extension string)","correct":"yargs().config({ extends: 'yargs-test-extends' })"},{"note":"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.","symbol":"config (CommonJS direct require)","correct":"const config = require('yargs-test-extends');"},{"note":"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.","wrong":"import { c } from 'yargs-test-extends';","symbol":"config (ESM direct import)","correct":"import config from 'yargs-test-extends';"}],"quickstart":{"code":"const yargs = require('yargs');\nconst assert = require('assert');\n\n// This example demonstrates how yargs loads configuration\n// from the 'yargs-test-extends' module via its 'extends' mechanism.\n// The 'yargs-test-extends' package's package.json specifies 'index.json' as its main.\n// The index.json contains { \"c\": 201 }.\n// The initial config sets 'a' to 2.\n\nconst argv = yargs()\n  .config({\n    a: 2,\n    extends: 'yargs-test-extends' // Yargs resolves this module's main file\n  })\n  .argv;\n\n// Verify that the initial config 'a' is preserved.\nassert.strictEqual(argv.a, 2, 'Value for `a` should be 2 from direct config.');\n\n// Verify that 'c' is loaded from the extended module.\nassert.strictEqual(argv.c, 201, 'Value for `c` should be 201 from extended module.');\n\nconsole.log('Yargs successfully extended configuration from yargs-test-extends.');\nconsole.log('Parsed argv:', argv);","lang":"javascript","description":"Demonstrates `yargs` loading configuration from an external Node.js module specified by `extends`."},"warnings":[{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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' })`.","message":"Attempting 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'`.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.1':68 'abil':109 'applic':46 'argument':32 'capabl':62 'command':30 'command-lin':29 'config':22 'configur':2,53,60,81,102,112,126 'consum':45 'contain':100 'current':65 'demonstr':74 'design':17 'dynam':59,113 'ecosystem':131 'ensur':124 'entri':91 'extend':3,10,24,111 'extern':84 'file':99,123 'fixtur':16 'function':25 'general':41 'general-purpos':40 'index.json':98 'inspect':88 'instal':115 'intend':38 'intern':15 'javascript':132 'json':122 'librari':34 'line':31 'load':61,80 'local':121 'main':90 'maintain':66 'manag':127 'mechan':105 'modul':5,86 'node.js':85 'packag':11,64,116 'pars':33 'point':92,94 'predefin':101 'primari':70 'purpos':42 'rather':48,117 'robust':125 'role':71 'serv':49 'sole':119 'sourc':54 'special':14 'static':52,97 'test':4,9,20,106 'unit':19 'use':43 'valu':103 'verifi':56,76 'version':67 'within':26,128 'yarg':1,8,28,57,78,107,130 'yargs-test-extend':7","created_at":"2026-04-25T04:59:39.777521+00:00","updated_at":"2026-04-25T04:59:39.777521+00:00","problems":[{"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' })`.","cause":"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`.","error":"Unexpected object received when requiring 'yargs-test-extends' directly."},{"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`.","cause":"The `yargs-test-extends` package has not been installed, but `yargs`'s `.config({ extends: 'yargs-test-extends' })` is attempting to resolve it.","error":"Module not found: Can't resolve 'yargs-test-extends'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/yargs-test-extends","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}