How to Clear Session Data When Testing with Laravel Dusk

Each time you run a browser test in Laravel Dusk you will share session and cookie data with other tests in your file. If you’re trying to test a login form or something similar you may run into issues where one test is using session data from a different test.

Here’s how you can clear and delete the session data between tests to ensure that each test is sanitized.

Open up /tests/DuskTestCase.php and create or update the tearDown() method with the following.

This will clear cookie data for every test you create. If you’d rather only do it for a single file or test, you can either move the tearDown() method into the test file you want to update or create a different method and call it inside of individual Laravel Dusk tests.


Vagrant Up Timing Out During SSH Auth Method Configuration

If you’re unable to load vagrant using vagrant up and the system is hanging on the message default: SSH auth method: private key  you may need to reset the operating system that VirtualBox believes it is loading.

VirtualBox has been known to reset the setting from 64bit to 32bit during updates or configuration changes. This causes the box to not load properly whether you are using vagrant or not.

  1. Open VirtualBox and select your box and click Configurations
  2. Select the General tab
  3. Change the version to whatever it was before. It most likely will need to be changed from 32bit to the 64bit version.

Setting up a great looking macOS OS X terminal/shell

Switch from bash to ZSH. I personally like using Oh My Zsh, which is a framework for managing themes, plugins and other good stuff related to ZSH.

Switch from the default terminal prompt to Pure, which cleans up how the terminal looks as you use it. It removes some noise from the prompt and keeps things organized.

Add the snazzy theme to your terminal which adds some nice colors.

Use Droid Sans Mono as the default terminal font.

Add ZSH Syntax Highlighting to Oh My Zsh. It helps with hinting terminal commands along with some extra interactivity with the command prompt.

Turn on vim syntax highlighting.

Getting Google reCAPTCHA to Work Locally on Vagrant

Typically you can use “localhost” in the reCAPTCHA settings if you want to test your app locally, but if you’re using vagrant to manage your local servers this won’t work.

You won’t be able to use “localhost” or your custom hostname, such as “” that’s hard coded into your host file for local development with reCAPTCHA if you’re using vagrant.

You’re going to need to use the IP address you assigned to the vagrant box when you created it. You can either view the config file related to the vagrant box or you can echo out $_SERVER[‘REMOTE_ADDR’] from your PHP app. That will give you the IP address that you can enter into the reCAPTCHA settings page next to your production URL.

Displaying WooCommerce Product Variation Order Totals

WooCommerce doesn’t have a built-in way to display order totals for product variations like size and color. This means you need to go through each order and total them manually for products that have variations, such as size. Continue reading “Displaying WooCommerce Product Variation Order Totals”

Better JavaScript Using Modern Techniques

I’m going to highlight some of my favorite modern JavaScript features in this post. Most of these are new to ES6, but a few of them are not. I call these features modern because they allow JavaScript to be written in a way that supports conciseness for better readability. This isn’t intended to summarize all of ES6. It’s mostly just tips for more readable and interactive code. Continue reading “Better JavaScript Using Modern Techniques”

HTML5 Canvas Object Rotation

There is no simple function that you can use to rotate objects within the HTML5 Canvas. To implement rotation you need to rotate the entire canvas context and draw your object on the rotated context and then rotate the entire thing that back to it’s normal state. While you’re doing that, you also need to update the coordinate space of the canvas context. Continue reading “HTML5 Canvas Object Rotation”

Even Row Heights for Columns With Bootstrap and AngularJS

When using AngularJS to iterate over and display a collection with Bootstrap columns you might notice that the columns don’t stack nicely unless they all have the same content height. If the content heights differ, then you’ll have some of them nested in strange places. Continue reading “Even Row Heights for Columns With Bootstrap and AngularJS”