Testing Laravel Applications with CircleCI & Dusk

I recently started a new project and wanted to give Laravel’s new test framework Dusk a try. Locally, this was quick to do and it worked first time – however when I then connected up CircleCI I needed to do a little extra work to get up and running. In short, the version of Google Chrome needs updating to a newer version and then things should be running well.

Firstly, make sure you’re up and running locally and your tests are passing (that’s half the work done, right?). You should have output similar to:

So, we’re all good at this point. Next, get your circle.yml file looking something like the following:

 

This will make sure you’re using PHP 7.1, start the site running in the background and allow dusk to run. You’ll need to make sure that the APP_URL value in your .env.testing file is pointing to 127.0.0.1. In the example above, we’re making sure that CircleCI adds an entry to /etc/hosts for ‘testing’.

Providing your tests now work, you’ll have a big green bar in CircleCI.

Tool to Create Mastodon OAuth2 Applications in Your Browser

At the moment, there isn’t a user friendly way of setting up new OAuth2 applications for use with Mastodon. You need to make an API request to do so. To help, I’ve written a small tool which allows you to do this securely in your browser.

You can use the tool at mastodon-create-app.ssx.tools or you can grab the source yourself from Github at ssx/mastodon-create-app.

If you have any ideas or feedback, please open an issue on the repo.

Appcelerator Titanium Starting an Intent/Activity Not Firing

If you’re a user of intents with Android and Appcelerator’s Titanium product, you may have instances where your intents don’t fire as you expect. A lot of sample code around the web for starting intents looks something like this:

The problem with arises when sometimes Ti.Android.currentActivity doesn’t correctly hold the current activity. When you then attempt to start an intent from the current activity, it does nothing. The way around this is to call startActivity from the current view, like this:

Which will fire the new intent every time.

Continuous Integration Testing an Appcelerator Titanium Mobile Application

I’ve recently been looking at unit testing some isolated components for a mobile application I’m working on. Part of the application is a calculations engine which I wanted to test against a known set of sample data and results.

There have been many attempts through the community at putting widely accepted testing frameworks throughout the last few years, but none felt too akin to what I wanted or how I wanted it to work. Most of the testing frameworks out there such as timocha run within the application via a simulator and this was something I wanted to avoid.

For version control I use both Github for personal projects and then Gitlab at work and for my larger personal projects. I wanted a solution that could run within Gitlab’s CI runner – which I use Docker.

I began by creating a Dockerfile which included the things needed to build an application. There were a few road blocks in the way. The image needed to have node, npm, Oracle Java 8, android-idk-linux and a few npm packages such as appcelerator, titanium, jasmine, tisdk.

Firstly, the appc command will require a username and password to login to to Appcelerator’s platform to fetch an SDK and produce a build – this wasn’t ideal. The appc tool won’t run under the root user (for good reason) which also meant employing runuser a few times to get commands to run.

A few very helpful conversations with Adam Paxton highlighted the useful tisdk npm package which will fetch and install SDKs and the open source ti NPM package can perform the open source version of appc which includes producing a build. You’ll also need to install some gcc libraries as well (they’re in the Dockerfile).

The producing a build part is needed with tiunit so that you can correctly include any alloy resources that you need (in my case, I had used alloy/moment in a few places which I ended up mocking instead. For reference, you can build your application using (adjust for platform you’re using):

appc run -p android -b

In the end, I managed to get my tiunit tests running, I’ll follow up with a sample application and test case for you to follow along with.

You can use the image from Dockerhub at hellossx/appcelerator-ci which is built automatically from the Github repo ssx/docker-appcelerator-ci. I used the following .gitlab-ci.yml configuration to have it run my tests:

If you prefer that as a gist, you can view it here.

Notes:

  • Hyperloop is a no-no using this method, without introducing your Appcelerator username/password into the scripts.
  • Introducing Appcelerator username/passwords would be trivial using Gitlab’s secret variables within their CI.