magic-test/magic-test-laravel

ok: RuntimeException with message 'Too many arguments, expected arguments "command".'

sidewaysglance opened this issue ยท 19 comments

Very close to being able to use this wonderful tool, any help much appreciated.

I run: ./artisan magic, a Chrome is being controlled by automated test software browser window comes up, dev console shows:

Magic Test started

I log in, dev console looks ok, no errors. Nothing in network tab relating to magic-test-laravel or testing generally.

If I select text & press Ctrl + Shift + A the dialogue box pops up saying assertion generated.

I go into psy shell, type ok but get the message:

RuntimeException with message 'Too many arguments, expected arguments "command".'
in:
Psy Shell v0.10.12 (PHP 8.1.2 โ€” cli)

No major changes are made to the ExampleTest.php which has the simplest initial test method in it:

    public function testBasicExample()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/')
                //    ->assertSee('Laravel');
                ->magic();
        });
    }

What could be wrong? Full output here:

*** Starting a ๐Ÿง™ Magic Test session...
PHPUnit 9.5.13 by Sebastian Bergmann and contributors.

Psy Shell v0.10.12 (PHP 8.1.2 โ€” cli) by Justin Hileman
New version is available (current: v0.10.12, latest: v0.11.1)

*** Welcome to your ๐Ÿง™ Magic Test session! ***

* To make a assertion press Ctrl + Shift + A on your browser.
* Type ok to magically write it to your test file.
  (make as many assertions as you wish)
* Type finish to finalize and save your test file.
* Type exit to leave.

๐Ÿ’ก Tip: Do not close your browser window before finalizing this session here.
>>> ok
RuntimeException with message 'Too many arguments, expected arguments "command".'

Using https://chromedriver.storage.googleapis.com/97.0.4692.71/chromedriver_mac64_m1.zip for the installed browser Version 97.0.4692.99 (Official Build) (arm64)

./artisan tinker works fine for the same project.

./artisan dusk returns OK (1 test, 1 assertion) when I switch commenting on magic() and assetSee('Laravel').

I'll try it on my M1 tomorrow morning with those versions

Seems to be related to PsySH maybe...

I think you are right - this is the bit that suggests this is the case:

Root composer.json requires magic-test/magic-test-laravel ^0.14.0 -> satisfiable by magic-test/magic-test-laravel[v0.14].
magic-test/magic-test-laravel v0.14 requires psy/psysh ^0.10.4 -> found psy/psysh[v0.10.4, ..., 0.10.x-dev] but the 
package is fixed to v0.11.1 (lock file version) by a partial update and that version does not match. 
Make sure you list it as an argument for the update command.

Further details follow...

composer create-project laravel/laravel magictest
cd magictest
composer require laravel/dusk
./artisan dusk:install

This downloads various ChromeDrivers to ./vendor/laravel/dusk/bin/, including: chromedriver-mac-arm, which, when run, shows

Starting ChromeDriver 97.0.4692.71 (adefa7837d02a07a604c1e6eff0b3a09422ab88d-refs/branch-heads/4692@{#1247}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

Then ...

composer require magic-test/magic-test-laravel --dev

from the last command I get the response:

Using version ^0.14.0 for magic-test/magic-test-laravel
./composer.json has been updated
Running composer update magic-test/magic-test-laravel
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires magic-test/magic-test-laravel ^0.14.0 -> satisfiable by magic-test/magic-test-laravel[v0.14].
    - magic-test/magic-test-laravel v0.14 requires psy/psysh ^0.10.4 -> found psy/psysh[v0.10.4, ..., 0.10.x-dev] but the package is fixed to v0.11.1 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require magic-test/magic-test-laravel:*" to figure out if any version is installable, or "composer require magic-test/magic-test-laravel:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

If I use the -W flag I get:

composer require magic-test/magic-test-laravel --dev -W
Using version ^0.14.0 for magic-test/magic-test-laravel
./composer.json has been updated
Running composer update magic-test/magic-test-laravel --with-all-dependencies
Loading composer repositories with package information
Updating dependencies
Lock file operations: 3 installs, 1 update, 0 removals
  - Locking magic-test/magic-test-laravel (v0.14)
  - Downgrading psy/psysh (v0.11.1 => v0.10.12)
  - Locking spatie/backtrace (1.2.1)
  - Locking spatie/laravel-package-tools (1.11.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 3 installs, 1 update, 0 removals
  - Downgrading psy/psysh (v0.11.1 => v0.10.12): Extracting archive
  - Installing spatie/laravel-package-tools (1.11.0): Extracting archive
  - Installing spatie/backtrace (1.2.1): Extracting archive
  - Installing magic-test/magic-test-laravel (v0.14): Extracting archive
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
[...]
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.

Updating .env to show APP_URL=http://magictest.test and running ./artisan dusk I get OK (1 test, 1 assertion).

Commenting out ->assertSee('Laravel');, adding ->magic(); & running ./artisan magic shows the browser window.

If I select text & press Ctrl + Shift + A the dialogue box pops up saying assertion generated.

Then ...

>>> ok
RuntimeException with message 'Too many arguments, expected arguments "command".'

Thanks again for all your help. By the way do you know that the Sponsor this project section shows no ways of sponsoring?

Any news on this? I assume it will be an issue for all Laravel installs ...

Any news on this? I assume it will be an issue for all Laravel installs ...

Sorry, I haven't had time to take a look at it yet. I'll reserve some time for it today.

Thanks in anticipation ...

@rightwayround I've fixed the psysh dependency (haven't updated it yet), but the command error doesn't seem to be limited to magic test. See: https://laracasts.com/discuss/channels/laravel/runtimeexception-with-message-too-many-arguments-expected-arguments-command

Looking into it..

@rightwayround i'm getting that on a clean laravel install, too

@rightwayround so it's a known issue: bobthecow/psysh#704

Using symfony/console:6.0.2 should fix it for you. I'll tag a release using the newest PsySH version

@rightwayround v0.15 has been tagged

Thanks for your efforts, but I am still having the same issue.

I rm -rf the magictest folder, redo the actions I took above & see the following:

โžœ  magictest ./artisan magic
*** Starting a ๐Ÿง™ Magic Test session...
PHPUnit 9.5.13 by Sebastian Bergmann and contributors.

Psy Shell v0.11.1 (PHP 8.1.2 โ€” cli) by Justin Hileman

*** Welcome to your ๐Ÿง™ Magic Test session! ***

* To make a assertion press Ctrl + Shift + A on your browser.
* Type ok to magically write it to your test file.
  (make as many assertions as you wish)
* Type finish to finalize and save your test file.
* Type exit to leave.

๐Ÿ’ก Tip: Do not close your browser window before finalizing this session here.
>>> ok
RuntimeException with message 'Too many arguments, expected arguments "command".'

My composer.json shows "magic-test/magic-test-laravel": "^0.15.0",.

My composer.lock shows:

[...]
           "require": {
               "psy/psysh": "^0.10.4|^0.11.1",
[...]
   "packages": [
[...]
       {
           "name": "psy/psysh",
           "version": "v0.11.1",
[...]

I have just been looking here (bobthecow/psysh#705) and can see it's an upstream problem. I will pester those guys. If you have any bright ideas on what I could do as a work around let me know? Otherwise thanks for everything.

Also, fix your sponsorship link!

โ€ฆ is it working for you @mateusjatenee?

Are you using valet?

@rightwayround have you tried this? bobthecow/psysh#705 (comment)

@mateusjatenee yes I did try that. I get the following - which is why I asked whether you were using valet:

โžœ  magictest composer global require symfony/console:6.0.2

Changed current directory to /Users/rightwayround/.composer
./composer.json has been updated
Running composer update symfony/console
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires symfony/console 6.0.2, found symfony/console[v6.0.2] but these were not loaded, likely because it conflicts with another require.
  Problem 2
    - mnapoli/silly 1.7.3 requires symfony/console ~3.0|~4.0|~5.0 -> found symfony/console[v3.0.0, ..., v3.4.47, v4.0.0, ..., v4.4.37, v5.0.0, ..., v5.4.3] but it conflicts with your root composer.json require (6.0.2).
    - laravel/valet v2.18.9 requires mnapoli/silly ^1.0 -> satisfiable by mnapoli/silly[1.7.3].
    - laravel/valet is locked to version v2.18.9 and an update of this package was not requested.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Running composer global update laravel/valet shows:

Changed current directory to /Users/rightwayround/.composer
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
17 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

... if there was an alternative standard (maybe sail, laradock, docker based) environment that works, that would be cool too.

hey! running in to this while running in sail. after trying (bobthecow/psysh#705 (comment)) it seems to return the same RuntimeException

Could throwing cash at this make the problem go away

@rightwayround I cannot replicate your error. Can you send me a list of the packages you have installed and their versions?