Moniker is a compact example module in this workspace providing a small React Native view, a test harness, and developer helpers.
Contents
MonikerViewcomponent and example tests.harness.jsfor quick manual verification.scripts/contains helper scripts used by the CLI.
Quick usage
- Import and render
MonikerViewin your app. Use the included__e2e_tests__for example tests.
Using the CLI
- This package provides the
test-monikerCLI. From the project root you can run it withnpx test-moniker.
Commands
doctor: Run environment and health diagnostics (checks adb, java, SDK, installed package versions and device state).--start-dev-server/-s: Start the metro development server and optionally run the Android build flow.
Common flags
--workspace <path>/-w <path>: override the auto-detected workspace root (accepts relative paths).--print-workspace/-p: print the resolved workspace available to handlers.--config <path>: path to a moniker config file (relative to workspace).--init-config: create a defaultmoniker.config.jsin the current working directory.--ci: CI-friendly mode (quiet console, writes logs, fail-fast behavior).--force/-f: bypass workspace validation (use with caution).--dry-run/-n: show actions without executing them.--verbose/-V: enable verbose output and logging.--json,--json-log,-j: output JSON/logging from commands (line-delimited when used).--log: enable textual log output to the default moniker log file (created under the workspacelogs/folder).--silent: reduce console output (write logs instead of printing to console).--capture-bugreport-on-crash: automatically capture an adb bugreport when a crash is detected.
Logging and JSON output
--log: enable textual log output to the default moniker log file (created under the workspacelogs/folder). The CLI will print the path when logs are saved.--silent: reduce console output; prefer writing logs instead of printing to stdout.--json,--json-log,-j: enable line-delimited JSON log entries. If a path is provided it will be used; otherwise JSON output will be emitted to stdout.
Tip: run npx test-moniker --help to view the full, current list of available flags and commands.
Pre-run flags
- The CLI supports marking handlers as pre-run flags using the handler chain method
.flags({ pre: true }). - Pre-run flagged handlers run before normal actions; use this to set up global runtime state, load configs, or instantiate loggers that other actions rely on.
- Example:
cli('--json-log').flags({pre:true}).do(() => { /* enable json logging before actions */ })
Environment
- When the CLI resolves a workspace it sets
TEST_MONIKER_WORKSPACEin the process environment. Handlers also receive avalues.workspaceproperty.
e2e Testing
- Test example,
projectRoot/__e2e_tests__/sampleTest.js
module.exports = function sampleTest({describe, it}) {//function name as test name
describe(sampleTest.name, () => {
it('harness basic sanity', async({ log, assert }) => {
log('init: basic sanity check (simulating work)');
//delay to simulate work
await new Promise(resolve => setTimeout(resolve, 1000));
assert.ok(true, 'basic truthy check');
});
});
};Examples
- Print resolved workspace:
npx test-moniker --print-workspace- Create a default config in the current working directory:
npx test-moniker --init-config- Start metro + build on Android (dev flow):
npx test-moniker --start-dev-server- Start metro and capture bugreports automatically when a crash is detected:
npx test-moniker --start-dev-server --capture-bugreport-on-crash- CI run writing JSON logs:
npx test-moniker --ci --json-log logs/moniker.json --start-dev-serverBest practices
- Prefer running
npx test-monikerdirectly rather than binding tonpm startso the CLI can be used from other workspaces and CI. - Use
--workspacewhen invoking from nested directories or from automation to ensure the correct project root is used. - Use
--json-login CI to capture machine-readable logs.
Notes for contributors
- The CLI auto-detects the workspace by walking parent directories looking for
app.jsonorpackage.json. The resolved workspace is injectable into handlers and exported onprocess.env.TEST_MONIKER_WORKSPACE. - The CLI tracks spawned child processes (metro, build, adb logcat) and performs graceful shutdown on SIGINT/SIGTERM.
License
- See the repository root for licensing information.