Asking ChatGPT about Laravel Livewire Standalone Testing

Laravel Livewire is incredibly powerful but if you're creating standalone package testing may be a challenge.

This morning I decided to ask ChatGPT to help me write a standalone test for a Laravel Livewire Package. 

ChatGPT has introduced a completely new era in computing. Looking back at my 30+ IT career this is definitely a watershed moment. ChatGPT is by far one of most disruptive technologies to become mainstream in years.

For programmers the beauty of ChatGPT is what I called the mentor and apprenticeship help. All of a sudden programmers have both a possible mentors and apprentices.

For the sceptics with blanket statements such as "ChatGPT makes mistakes" and "be careful", my retort is that these mistakes and caution is not a problem at all. ChatGPT is revolutionary and the quicker you learn to use and embrace is the better.

So this morning I thought about some challenges I recently had with a ecommerce subscriptions payment library. The library uses Laravel Livewire and is a standalone package. It already has some PHPUnit tests, but the tests were copied from another package and is all to do with the billing code and not the UI.

So I asked ChatGPT the question:

Can you show me how to write a Laravel Livewire standalone package?

Well ChatGPT delivered the goods. It provided a great outline on how this would work. Sure, it wasn't perfect and there was a mistake right at the start with a non-existent composer command. But nevertheless, I had a clutter free bare bones example of Livewire standalone testing.

A few days I also tried doing tesing on my standalone package, but adding anything UI related quickly fell over even though I had Orcestra setup.

In the end I also relied on a recent google search where Freek of Spatie referred someone to their Laravel Livewire Wizard which does standalone testing.

The final result was me using the basics grasped from ChatGPT and then stripping down Spatie's package to the bare essentials.

Here is what I came up with:

https://github.com/fintech-systems/livewire-standalone-testing

Updated: 1 year ago

© 2022 Eugene's Blog