Laravel dusk asserting for 404 errors - laravel

I'm trying to use laravel dusk to test for 404 not found error. Specifically when loading an image. After reading the laravel dusk documentation I've found no asserts that could help me test if a 404 exception occurs.
Is there a good way of getting a browser test to know whether a resource has failed loading or is it simply not possible?

There is intentionally no way to access HTTP status codes:
https://github.com/laravel/dusk/issues/422
https://github.com/facebook/php-webdriver/issues/470

You can use browser -> driver -> manage() -> getLog('browser') to get the log and see if there is a 404 Error

Related

How to hide Laravel's 405 Method Not Allowed error screen?

When directly accessing a URL which use Route::post(), Laravel shows the following 405 Method Not Allowed error screen:
Oops! An Error Occurred
The server returned a "405 Method Not Allowed".
Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
I think it is not good to give bad people information about the correct method. Am I right?
How to hide 405 Method Not Allowed error screen and show 404 Not Found error instead?
It is better to configure .env or Laravel than to configure nginx or apache.
And I don't want to write 404 error redirect in every controller methods.
I want to hide the error screen only in the production because it is good to know that method is not correct while developing (debug mode is on).
Thanks to #Don'tPanic in the comments of my question, I found the answer.
Laravel offers the option to hide 405 error screen.
You can change 405 error to 404 error and display 404 Not Found error page instead of 405 error page without writing code in every controller action method.
For more detail, see the answer and documentation below:
how to handle 405 error for displaying as webpage laravel
The Render Method
https://laravel.com/docs/5.8/errors#render-method

Laravel snappy returning Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error

I am using laravel snappy based on wkhtmltopdf, everything was ok, but now on server and local I am getting this error:
Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error.
And
Blocked access to file /var/www/app/public/css/app.css
And no image is rendered in pdf.
This is so strange and discouraging to always being debugging snappy.
I do not understand the issue and do not know how to fix it.
anyone can help me please?
thanks
With Laravel Snappy, you need to use this option
enable-local-file-access
like this :
->setOption('enable-local-file-access', true)
I also discover this link after : wkhtmltopdf, 0.12.6, Warning: Blocked access to file. It will help too.

_PS_MODE_DEV_ not working in Prestashop 1.6.1.11

I'm trying to install/configure a theme in a new/clean Prestashop 1.6.1.11 installation. I was able to install/enable the theme, but when I try to view the page it comes back with a 500 error message.
I changed _PS_MODE_DEV_ to true in /config/defines.inc.php but still I only get:
The x.x.x.x page isn’t working
x.x.x.x is currently unable to handle this request.
HTTP ERROR 500
It's not showing the error debug information so that I can troubleshoot.
Anywhere else where I need to enable this?
Thanks
You are not able to view the error even after enabling error debugging because the error is being generated before the error debugging is set to enabled. In order to debug your issues, you can check the error log on your server.
In case of Apache you can check following file:
/var/log/apache2/error.log

500 internal server error in Laravel 5.2

I have created a new Laravel project. But when I run the command php artisan serve in the browser I am getting an 500 internal server error with no error log from Laravel even if debug mode is set to true. Please suggest.
Found similar issue on laracasts:-
[SOLVED] [L5] New: Can't display errors, 500 internal server error
It's been fixed by enabling write permission to storage folder.
Hope this helps.

Laravel - how to show errors on terminal rather than log file?

I'm watching TDD by Example Laracast and I see whenever he runs phpunit and a fatal error or an uncaught exception is thrown, it gets logged in the terminal like this:
MyControllerTest::test_it_shows_create_form
InvalidArgumentException: View [mycontroller.create] not found
But whenever I run phpunit and get a fatal error or an uncaught exception, it just get logged directly to storage/logs/laravel.log instead of showing it in the terminal, which makes it harder and slower to do TDD.
Is there a configuration I might be missing that's causing me this issue?
Edit:
My console outputs this
MyControllerTest::test_it_shows_create_form
Failed to assert 200 equals 500
The failed assertion is a $this->assertResponseOk(), and since something is wrong (an uncaught exception maybe) http response code is 500.
But as you can see, it won't show me what the error is
Testing with PHPUnit, Behat, etc. runs your application in a different environment. So basically you should enable debugging for the environment that your test suite is using. If I recall correctly, test suites run your application in the testing environment. In that case you should create a .env.testing file in your root directory and enable debug option there.

Resources