Can Laravel Dusk test results be logged? - laravel

Dusk is providing individual logs for tests that returned failures / warnings in the console, but what I'm really after is one big log file or report that lists the pass/fail status of each test in my Dusk script.
Can anyone suggest a way to go about this? I can't find an answer anywhere but it seems like it should be a relatively common thing to need so I'm sure I've overlooked something.

You can use PHPUnit's logging:
php artisan dusk --log-junit junit.log
php artisan dusk --log-teamcity teamcity.log

Related

Installing (Laravel) Dusk on Lumen

I am building a self-consuming Lumen API that has a single Lumen view (which serves the HTML to which the React app is appended).
I was able to install Dusk with
composer require --dev laravel/dusk
which seemed successful.
However, when I run
php artisan dusk:install
I get
There are no commands defined in the "dusk" namespace.
I know Lumen has a stripped-down php artisan. But, wondering if I can add the commands to the "dusk" namespace, or if anyone has successfully used Dusk with Lumen.
Thanks to Jared's answer,
I found I had to manually register Dusk's service provider before I could run php artisan dusk:install. The current Laravel documentation doesn't mention registering it, but it seems like it might have to be done for Lumen.
So all I had to do was add
if (app()->environment('local')) {
$app->register(Laravel\Dusk\DuskServiceProvider::class);
}
to /bootstrap/app.php below the Register Service Providers comment.
As Jared mentions, you don't want it to register in production environments so I stuck it in a conditional.
Once added, I was able to run php artisan dusk:install and got Dusk scaffolding installed successfully.
Be sure you have the .env file setup correctly.
The APP_ENV should be set to local or testing for dusk to work.
Also check if it's was correctly installed by checking the Register Service Providers in your bootstrap/app.php file. Dusk should be listed there.
If you are manually registering Dusk's service provider, you should never register it in your production environment, as doing so could lead to arbitrary users being able to authenticate with your application.

Not working on Laravel Controller, Working on Tinker

Guzzle version(s) affected: 6.3 Laravel: 5.6.3 PHP: 7.2.10
Description
If I am trying to get response in tinker
$client = new \GuzzleHttp\Client();
$response = $client->get($url);
json_decode($response->getBody())
I am getting response as expected.
but in my controller
$object_res = $client->get($url);
I am getting error
"cURL error 3: malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)",…}
Which means, the url is incorrect, but as I have described, this working perfectly in tinker.
Note
I am getting everything working perfectly in my localhost, this is occurring only on my test server.
Please let me know, if I need to give additional information.
Tinker uses a different runtime than your application, this could be causing an issue because in one scenario. php goes directly from your box to the api server and in the other it goes through your webserver before making the request.
The first thing to do would be to clear your laravel cache and config with
php artisan cache:clear
and
php artisan config:clear
if that fails I would look into the cross-domain restrictions or settings on your web server.
Please check for Guzzle requirements on your server. specially
To use the PHP stream handler, allow_url_fopen must be enabled in your system's php.ini.
I just ran into this problem on my testing server, I found it using cockpit. but my problem was with alouy/youtube. check selinux if you have that on your production server. check file permission of .env too. Hard to give a solution when the variables of your server are not presented.
also Read your laravel logs, that presented the solution to me.
hope this helps.

Laravel artisan command from controller

I update my .env file using a function in my controller.
After I save the settings I need to update, I call Artisan::call('config:cache') to clear the cache of my site's configuration.
Everything works fine on localhost, but when I try to clear config cache on production, it doesn't work. (No warnings or errors.)
I even tried with --no-interaction option attached to this CLI command.
Did anyone have this problem and know what causes it?
check into the PHP security settings and make sure you can run these exec,passthru,shell_exec functions in your server.

Why Laravel project website response is over 10 seconds long on artisan localhost only?

When I work with my local version of project then every action taken on website needs around 10 seconds long response. It's so frustraiting. And it hapens only on my PC. How can I prevent this action?? Downloading project from VCS to new folder helps for short time. I have Windows 10, Laravel 5.4, PHP 7.0.15. Commands
php artisan cache:clear
and
php artisan optimize
are not helping. Please, can anyone help?
Do you use xdebug? It can slow down application.
Also check your laravel debug option in .env file, it should be:
APP_DEBUG=false
That was laravel.log. I deleted it and everything seems to be ok. The file had 56MB of logs. Now i have to find out how to stop logging or create new log file every 2MB.

Getting strange errors installing a Laravel application

The first problem I'm running in to is that when installing I receive a mysql error stating that a table cannot be found. Of course it can't, I finished installing the dependencies much less run the migration. The error was being triggered by a Eloquent query in a view composer. After commenting out the entirety of my routes file Composer let me continue.
I proceed to uncomment out my route file - I get the error once again trying to run any artisan commands (can't migrate my database because I haven't migrated my database). Repeat the solution for step one and I've migrated my database.
Artisan serve is now serving me my layout file in the terminal and exiting. I'm at a bit of a loss to troubleshoot this. I assumed that it was possibly a plugin, trying to disable plugins one by one results in:
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
and being served up my layout file in the terminal.
It seems that the error is directly related to this function in my routes file:
View::composer('layouts.main', function($view) {
$things = Thing::where('stuff', 1)->orderBy('stuff')->get();
$view->with(compact('things'));
});
This isn't a new introduction to the application however so the underlying cause is coming from somewhere else.
As i said in the comment, if you are finding database errors in production server but not in local, then
check database credentials. if its ok then....
check the different configs in the environment.
using profilers(any) will let you know what environment you are in.

Resources