I am trying to run my unit tests using the built in laravel commands.
I am getting the following error when running php artisan test
.
ERROR Command "test" is not defined. Did you mean one of these?
Not sure why the command is not available.
When I run php artisan
I get the following available commands.
Laravel Framework 10.3.0
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
about Display basic information about your application
clear-compiled Remove the compiled class file
completion Dump the shell completion script
db Start a new database CLI session
docs Access the Laravel documentation
down Put the application into maintenance / demo mode
env Display the current framework environment
help Display help for a command
inspire Display an inspiring quote
list List commands
migrate Run the database migrations
optimize Cache the framework bootstrap files
serve Serve the application on the PHP development server
tinker Interact with your application
ui Swap the front-end scaffolding for the application
up Bring the application out of maintenance mode
auth
auth:clear-resets Flush expired password reset tokens
cache
cache:clear Flush the application cache
cache:forget Remove an item from the cache
cache:prune-stale-tags Prune stale cache tags from the cache (Redis only)
cache:table Create a migration for the cache database table
channel
channel:list List all registered private broadcast channels
check
check:gd_stats_dashboard_data Check gd_stats_dashboard_data
check:users_dashboard_clients Check users at dashboard clients
clear
clear:cache_data Clear cache data.
config
config:cache Create a cache file for faster configuration loading
config:clear Remove the configuration cache file
db
db:monitor Monitor the number of connections on the specified database
db:seed Seed the database with records
db:show Display information about the given database
db:table Display information about the given database table
db:wipe Drop all tables, views, and types
debugbar
debugbar:clear Clear the Debugbar Storage
elasticsearch
elasticsearch:create-service-index ElasticSearch - Create services index
env
env:decrypt Decrypt an environment file
env:encrypt Encrypt an environment file
event
event:cache Discover and cache the application's events and listeners
event:clear Clear all cached events and listeners
event:generate Generate the missing events and listeners based on registration
event:list List the application's events and listeners
financials
financials:export Financials Export to nova
key
key:generate Set the application key
lang
lang:publish Publish all language files that are available for customization
laravel-elasticsearch
laravel-elasticsearch:utils:alias-create
laravel-elasticsearch:utils:alias-remove-index
laravel-elasticsearch:utils:alias-switch-index
laravel-elasticsearch:utils:index-create
laravel-elasticsearch:utils:index-create-or-update-mapping
laravel-elasticsearch:utils:index-delete
laravel-elasticsearch:utils:index-exists
livewire
livewire:configure-s3-upload-cleanup Configure temporary file upload s3 directory to automatically cleanup files older than 24hrs
livewire:copy Copy a Livewire component
livewire:delete Delete a Livewire component
livewire:discover Regenerate Livewire component auto-discovery manifest
livewire:make Create a new Livewire component
livewire:move Move a Livewire component
livewire:publish Publish Livewire configuration
livewire:stubs Publish Livewire stubs
make
make:cast Create a new custom Eloquent cast class
make:channel Create a new channel class
make:command Create a new Artisan command
make:component Create a new view component class
make:controller Create a new controller class
make:event Create a new event class
make:exception Create a new custom exception class
make:export Create a new export class
make:factory Create a new model factory
make:import Create a new import class
make:job Create a new job class
make:listener Create a new event listener class
make:livewire Create a new Livewire component
make:mail Create a new email class
make:middleware Create a new middleware class
make:migration Create a new migration file
make:model Create a new Eloquent model class
make:notification Create a new notification class
make:observer Create a new observer class
make:policy Create a new policy class
make:provider Create a new service provider class
make:request Create a new form request class
make:resource Create a new resource
make:rule Create a new validation rule
make:scope Create a new scope class
make:seeder Create a new seeder class
make:test Create a new test class
migrate
migrate:fresh Drop all tables and re-run all migrations
migrate:install Create the migration repository
migrate:refresh Reset and re-run all migrations
migrate:reset Rollback all database migrations
migrate:rollback Rollback the last database migration
migrate:status Show the status of each migration
model
model:prune Prune models that are no longer needed
model:show Show information about an Eloquent model
notifications
notifications:table Create a migration for the notifications table
optimize
optimize:clear Remove the cached bootstrap files
package
package:discover Rebuild the cached package manifest
queue
queue:batches-table Create a migration for the batches database table
queue:clear Delete all of the jobs from the specified queue
queue:failed List all of the failed queue jobs
queue:failed-table Create a migration for the failed queue jobs database table
queue:flush Flush all of the failed queue jobs
queue:forget Delete a failed queue job
queue:listen Listen to a given queue
queue:monitor Monitor the size of the specified queues
queue:prune-batches Prune stale entries from the batches database
queue:prune-failed Prune stale entries from the failed jobs table
queue:restart Restart queue worker daemons after their current job
queue:retry Retry a failed queue job
queue:retry-batch Retry the failed jobs for a batch
queue:table Create a migration for the queue jobs database table
queue:work Start processing jobs on the queue as a daemon
route
route:cache Create a route cache file for faster route registration
route:clear Remove the route cache file
route:list List all registered routes
schedule
schedule:clear-cache Delete the cached mutex files created by scheduler
schedule:list List all scheduled tasks
schedule:run Run the scheduled commands
schedule:test Run a scheduled command
schedule:work Start the schedule worker
schema
schema:dump Dump the given database schema
send
send:invoice_next_email Send invoice next email.
send:invoiceemail Send invoice emails.
session
session:table Create a migration for the session database table
storage
storage:link Create the symbolic links configured for the application
stub
stub:publish Publish all stubs that are available for customization
synchronize
synchronize:ad-am-roles Synchronize ad am roles via nova api.
synchronize:adp_api_hr_workers_data Synchronize adp api hr workers data.
synchronize:asana_run Synchronize asana_run
synchronize:clients Synchronize Clients via nova api.
synchronize:dashboardclientsreport Synchronize Dashboard clients via nova api.
synchronize:dashboards Synchronize dashboards via nova api.
synchronize:employee_client_stats Synchronize employee_client_stats
synchronize:employee_stats Synchronize employee_stats
synchronize:fifteenfive Synchronize fifteenfive
synchronize:gd_report synchronize gd_report
synchronize:google_run13 Synchronize google 13.
synchronize:google_run6 Synchronize google 6.
synchronize:google_run_variable_ad_spend_tracker Synchronize synchronize:google_run_variable_ad_spend_tracker.
synchronize:google_web_dev_billing_synchronize Synchronize google deb dev billing synchronize
synchronize:industry SynchronizeIndustry via nova api.
synchronize:industry_clients Synchronize Industry Clients via nova api.
synchronize:pad_employees Synchronize pad_employees google doc
synchronize:reportblueprints Synchronize ReportBlueprints via nova api.
synchronize:reportstaffing Synchronize ReportStaffing via nova api.
synchronize:reportunderpacing Synchronize ReportUnderpacing via nova api.
synchronize:salesforce_run Synchronize salesforce run
synchronize:salesforce_run3 Synchronize salesforce run3
synchronize:salesforce_run4 Synchronize salesforce run4
synchronize:salesforce_run5 Synchronize salesforce run5
synchronize:salesforce_run6 Synchronize salesforce run6
synchronize:strategist Synchronize strategist via nova api.
synchronize:synchronizeemployeeleadreport Synchronize Synchronize Employee Lead Report
synchronize:user_titles Synchronize ADP titles via nova api.
ui
ui:auth Scaffold basic login and registration views and routes
ui:controllers Scaffold the authentication controllers
vendor
vendor:publish Publish any publishable assets from vendor packages
view
view:cache Compile all of the application's Blade templates
view:clear Clear all compiled view files
I’m using the latest version of laravel 10 and PHP 8.1.
I’m seeking any solutions that anyone may have. Thanks!
3
Answers
I was missing the following package
nunomaduro/collision
Try running
composer require nunomaduro/collision
to resolve the issue.It worked for me
I ran
composer update
and that fixed the issue for me.I’ve tried this at another time I faced similar problem and it fixed it for me.
PS: Running this command may cause packages you don’t want to be updated to be updated. it can introduce breaking changes if the updated packages have made incompatible changes so proceed with caution.
I found the solution here:
If you do
composer install -o --no-dev
, you will not be able to run php artisan testI will never say I tried to run
php artisan test
on production