Testing Mobile App in AWS Device Farm using Appium and Node

· Reading time: ~6 minute(s) (1185 words) programming javascript react-native aws node

Warning: this post is quite code heavy as I offer our solution as an example

At work, we’ve been working on a mobile app for our customers. We’ve been looking at automated testing to interact with the app like a user would on a device and came across Appium and Detox as potential options that wouldn’t cost too much to run.

As we primarily worked on Windows machines, Detox was out of the running as it seems to be only guaranteed support on MacOS, so we started looking at Appium instead. AWS Device Farm supports this already, so this looked promising and a good place to start.

(Continue reading)

Configuring NGINX to work with React Router

· Reading time: ~1 minute(s) (159 words) programming javascript nginx tech

When using the BrowserRouter that’s provided by React Router, you’ll find that if you’re navigating within the site to the various URLs, they will work. However if you bookmarked one of those URLs, or refreshed the browser on a URL, it will return a 404.

If you’re using Webpack’s devserver, then you can get around it with a setting in the webpack.config.js file:

devServer: {
  // your other webserver settings
  historyApiFallback: true
}

This setting makes webpack aware of the historyApi that is used by React Router and essentially just redirects any unknown URLs back to the root.

(Continue reading)

How to test a custom React hook component

· Reading time: ~3 minute(s) (531 words) programming javascript react testing

As part of my GameBrowser side-project, I’m at the stage where I wanted to start improving the UI a bit. This included needing to define a way of filtering the servers in the list, because they’re all saved together at the moment. As a first attempt, I opted for a simple Dropdown control and decided to make it generic using a custom React Hook.

The result was the creation of useDropdown.

(Continue reading)

Basic Setup for React Projects in 2020

· Reading time: ~7 minute(s) (1399 words) programming javascript react

I’ve seen a lot of people using project initialisation tools to create their new React projects over the years, in particular create-react-app. While I do see there are some benefits to these tools (in particular for newcomers), these tools do have their disadvantages.

I cloned a repository the other day which was using create-react-app, and an npm i installed over 2000 packages! This is a hell of a lot to download just to be able to run some code locally. Yes, these packages will be cached, but if you take into account the time it takes for one dev, multiply that across a team of devs (also accounting for devs trashing their local repos and re-cloning), this could be a reasonable bit of time lost. This time is often lost at times where developers are feeling most productive too.

(Continue reading)

How I Built My Custom Hugo Pagination

· Reading time: ~5 minute(s) (1011 words) post programming gohugo.io

I’ve been planning on improving the pagination control for my blog for some time, but it always seemed a bigger job than I really wanted to work on in my spare time, but I was wrong. The only complexity was around the weird templating syntax that I hadn’t really got to grips with fully yet.

So I did some research first, why re-invent the wheel right? And I came across a really good tutorial from Glenn McComb where he went through how he built his, and seeing his examples, along with his explanations, made the syntax sink in better. I’d recommend giving his page a read first, as mine is based upon his with a few changes.

(Continue reading)

View Hugo served content on another device on network

· Reading time: ~1 minute(s) (190 words) post gohugo.io web

When you want to view content served by a locally running instance of Hugo on another device, you have to specify a few extra things so it will work correctly.

When you start the Hugo server locally, it will show the following output:

$ hugo server -w
...
(some output omitted here for brevity)
...
Web Server is available at //localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Because it’s bound to your localhost IP, you can’t just open port 1313 on your computer via a firewall and access Hugo from another device. You have to bind Hugo to the network IP instead (To find out the IP, try ipconfig on Windows or ip a on Linux).

(Continue reading)

Debugging a dotnetcore application hosted in a local IIS server

· Reading time: ~1 minute(s) (153 words) programming visualstudio dotnet core

When debugging a dotnet framework application that is hosted in a local IIS server, you would usually identify the w3wp.exe instance running the Application Pool and attach your Visual Studio instance to it. Sure you might get some issues with modules not loading, but on the whole this technique allows you to debug your application through IIS.

However, with dotnet core applications, things are a little different as they’re not ran as managed code from within a w3wp.exe instance but instead from within a dotnet.exe instance, so this is the process you should attach your Visual Studio instance to when debugging dotnet core.

(Continue reading)

Moq - Setup Mock method specifying parameters of type

· Reading time: ~2 minute(s) (255 words) csharp programming testing moq

When working on my GameBrowser project this evening, I wanted to verify that a method setup on a mock object had been called when a property of the parameter object was a particular value.

My scenario was that I was writing a unit test for the Quake3 protocol client and within that protocol client, I build the payload to include the 4-byte prefix data, so I needed to test that it was doing that payload building part correctly. I may extract this logic out in the future if I need to, but currently it’s only used within the Quake3 protocol so it can remain here for now.

(Continue reading)

Creating a Terraria server in Docker on a Raspberry Pi 4B

· Reading time: ~7 minute(s) (1367 words) gaming docker infrastructure

Terraria is a sandbox style game, similar in many ways to Minecraft, but yet different enough for many to argue otherwise!

When the Steam sale started, and Terraria was only £3.49, it made sense to give it a go. I’d tried it on a console in the past but found the controls a little cumbersome compared to a mouse and keyboard. My son also got it on his Steam account, as did a few of his friends, so we needed to find a way to get a server running where they could all play together or individually on a single world.

(Continue reading)

HP DM1-4027 Netbook locks up in Linux due to Thermal Event

· Reading time: ~1 minute(s) (168 words) techsupport dm1 notes

Sometimes in Linux I’ve noticed that the laptop will lock up, often in high CPU situations. This appears to be caused by some sort of thermal support (or lack of) and after some research, you can disable the thermal support within the OS and allow the BIOS to take over instead.

This is done by editing the grub entry to add thermal.off=1 at the end of the linux boot line which would result in the following (replacing {uuid} with your own UUID):

(Continue reading)