What Happens When You Don't Test in Safari
I decided to write about a major bug I recently encountered in our platform.
In Endtest, there is a section where users can view the test execution logs:
It's a critical component, and that's where it occurred.
1. The Bug
We recently made a change to improve the timestamps.
In our database, we store all the timestamps in UTC time zone, in a basic format:
And we wanted to display the timestamps in a more friendly way, while also converting them to the time zone of the user:
February 10, 2022, 14:31:15
It worked great in Chrome, Edge and Firefox, but not in Safari:
2. The Fix
The issue was coming from this line:
unixTimestamp = new Date(the_timestamp).getTime() / 1000 - (diff*60);
As you can see, it's a really basic one, nothing fancy or risky.
Turns out Safari has an issue with spaces in timestamps, and the solution is to replace each space with a T, like this:
the_timestamp = the_timestamp.replace(' ', 'T');
3. The Lesson
No unit or Jest test could have captured this issue.
The only way to detect such an issue is to run functional tests in Safari.
And that cross-browser testing is more relevant than ever.
4. The Rise of Safari
More and more folks are using Safari, they're loving the privacy-focused aspect of it.
Not testing on Safari means that you might be ignoring 20% of your users.
I'm also using it, but only on my phone. Chrome is still my desktop browser.
5. The Democratization of Automated Testing
We've always advocated for testing in multiple browsers, that's why Safari was always an option in our platform:
By providing browsers in the cloud, anyone can run tests on Safari, regardless of what operating system they're using.
And by proving a low-code interface, anyone can create automated tests in a few minutes, even without writing code.
The Test Automation space has always had its fair share of gatekeepers, and we're getting them out of the way.