PHPackages                             tembra/pest-plugin-x-args - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. tembra/pest-plugin-x-args

ActiveLibrary[Framework](/categories/framework)

tembra/pest-plugin-x-args
=========================

The Pest X-Args Plugin

2.0.0(2y ago)17MITPHPPHP ^8.1

Since Jan 13Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tembra/pest-plugin-x-args)[ Packagist](https://packagist.org/packages/tembra/pest-plugin-x-args)[ GitHub Sponsors](https://github.com/tembra)[ RSS](/packages/tembra-pest-plugin-x-args/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Pest X-Args Plugin
==================

[](#pest-x-args-plugin)

This repository contains the Pest X-Args Plugin.

This plugin add to Pest the functionality to accept `--x-` arguments and access them from the test cases.

> If you want to start testing your application with Pest, visit the main **[Pest Repository](https://github.com/pestphp/pest)**.

Installation
------------

[](#installation)

Install the plugin with **[Composer »](https://getcomposer.org)**.

```
composer require tembra/pest-plugin-x-args --dev
```

Versioning
----------

[](#versioning)

This plugin is using **[Semantic Versioning »](https://semver.org/)**

- Major versions will always be the same as Pest
    - v2.x works with Pest v2.x

Usage
-----

[](#usage)

Run Pest with any `--x-` argument you want to be available to test cases.

```
vendor/bin/pest --x-username=random --x-password=secret
```

If using a Composer script don't forget to use `--`, the special argument operator, after script name.

```
composer test-script-name -- --x-username=random --x-password=secret
```

In you test cases use the `hasXArg()` and `getXArg()` functions.

```
use function Tembra\Pest\Plugins\XArgs\{hasXArg};
use function Tembra\Pest\Plugins\XArgs\{getXArg};

it('has --x-username and --x-password argument', function () {
    $hasUsername = hasXArg('username');
    $hasPassword = hasXArg('password');

    expect($hasUsername)->toBe(true)
        ->and($hasPassword)->toBe(true);
});

it('can login with valid credentials', function () {
    $username = getXArg('username');
    $password = getXArg('password');

    if (null === $username || null === $password) {
        $this->fail('You need to send valid username/password through command line.');
    }

    // try to login with $username and $password
    // and make expectations and/or assertions with result
});
```

About arguments
---------------

[](#about-arguments)

The arguments are firstly processed by Pest through `Symfony\Component\Console\Input\Input` and then sent to this and others plugins. So everything that works there should work here.

Right away this plugin identifies the `--x-` argument and then the first equal sign (`=`) to break the argument in two parts. Then it removes the `--x-` from the first part.

Some statements:

- Arguments have a `key` and a `value`.
- In argument `--x-test=true` the key is `test` and the value is `true`.
- Both `key` and `value` are always of type `string`.
- Arguments may have only a `key` like `--x-active`. When this is the case the `value` is an empty string.
- Arguments `key` are case insensitive.
- Arguments `key` can not have an equal sign (`=`).
- Arguments `key` may use special chars if properly escaped, except the equal sign (`=`).
- Arguments with the same `key` overwrites each other. The last remains.
- Arguments without a `key` are not made available (e.g. `--x-=value`).
- Arguments `value` may be between quotes (e.g. `--x-key="complex value"`).
- Arguments `value` may use special chars if properly escaped.
- Unavailable arguments return `false` on `hasXArg()` and `null` on `getXArg()` calls.

To check some crazy usages you may look at `tests/PluginTest.php` and even run it with Pest 🚀.

Motivation
----------

[](#motivation)

Necessity to access specific and sensitive values (like a password) on test cases without the use of environment variables or files at all to do not take the risk to commit them to a local or remote code repository, even knowing that we could add these files to `.gitignore`.

Contributing
------------

[](#contributing)

Have any questions, found bugs or want to discuss/implement new functionalities? Do not hesitate to post an Issue and/or make a Pull Request if you can.

More Pest
---------

[](#more-pest)

- Explore Pest docs at **[pestphp.com »](https://pestphp.com)**
- Follow Pest on Twitter at **[@pestphp »](https://twitter.com/pestphp)**
- Join Pest community at **[discord.gg/kaHY6p54JH »](https://discord.gg/kaHY6p54JH)** or **[t.me/+kYH5G4d5MV83ODk0 »](https://t.me/+kYH5G4d5MV83ODk0)**

Pest is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

848d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/949f38e7454c8c518d79939320f3a9d35955375cc748f5fefa5bb9a5bbb01f98?d=identicon)[tembra](/maintainers/tembra)

---

Top Contributors

[![tembra](https://avatars.githubusercontent.com/u/6340360?v=4)](https://github.com/tembra "tembra (2 commits)")

---

Tags

command-linepestphppestphp-addonphppluginplugin-repotesttestingunit-testingphpplugintestingunitcommand-lineframeworktestpestparameterparametersargumentargumentsxargsarg

### Embed Badge

![Health badge](/badges/tembra-pest-plugin-x-args/health.svg)

```
[![Health](https://phpackages.com/badges/tembra-pest-plugin-x-args/health.svg)](https://phpackages.com/packages/tembra-pest-plugin-x-args)
```

###  Alternatives

[defstudio/pest-plugin-laravel-expectations

A plugin to add laravel tailored expectations to Pest

98548.9k4](/packages/defstudio-pest-plugin-laravel-expectations)[pestphp/pest-plugin-stressless

Stressless plugin for Pest

67792.6k16](/packages/pestphp-pest-plugin-stressless)[jonpurvis/lawman

A PestPHP Plugin to help with architecture testing SaloonPHP integrations

4027.7k8](/packages/jonpurvis-lawman)[spatie/pest-plugin-route-testing

Make sure all routes in your Laravel app are ok

13753.8k](/packages/spatie-pest-plugin-route-testing)[milroyfraser/pest-plugin-gwt

Given When Then(GWT) Plugin for Pest

10332.1k1](/packages/milroyfraser-pest-plugin-gwt)[ozzie/pest-plugin-nest

Nest Pest PHP tests for better organization and readability

2028.3k](/packages/ozzie-pest-plugin-nest)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
