magic-test / magic-test-laravel

MIT License
454 stars 21 forks source link

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

Open sidewaysglance opened 2 years ago

sidewaysglance commented 2 years ago

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').

mateusjatenee commented 2 years ago

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

mateusjatenee commented 2 years ago

Seems to be related to PsySH maybe...

sidewaysglance commented 2 years ago

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?

sidewaysglance commented 2 years ago

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

mateusjatenee commented 2 years ago

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.

sidewaysglance commented 2 years ago

Thanks in anticipation ...

mateusjatenee commented 2 years ago

@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..

mateusjatenee commented 2 years ago

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

mateusjatenee commented 2 years ago

@rightwayround so it's a known issue: https://github.com/bobthecow/psysh/issues/704

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

mateusjatenee commented 2 years ago

@rightwayround v0.15 has been tagged

sidewaysglance commented 2 years ago

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",
[...]
sidewaysglance commented 2 years ago

I have just been looking here (https://github.com/bobthecow/psysh/issues/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!

sidewaysglance commented 2 years ago

… is it working for you @mateusjatenee?

Are you using valet?

mateusjatenee commented 2 years ago

@rightwayround have you tried this? https://github.com/bobthecow/psysh/issues/705#issuecomment-1028522039

sidewaysglance commented 2 years ago

@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!
sidewaysglance commented 2 years ago

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

LarsWiegers commented 2 years ago

hey! running in to this while running in sail. after trying (https://github.com/bobthecow/psysh/issues/705#issuecomment-1028522039) it seems to return the same RuntimeException

sidewaysglance commented 2 years ago

Could throwing cash at this make the problem go away

mateusjatenee commented 2 years ago

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