Week 15 - Advanced Testing & Deployment

Week 15 - Advanced Testing & Deployment

·

6 min read

This week our bootcamp track has moved on to a new project. This is designed for us to put our learning into practice with a little more independence, adding in some concepts and exploring our API builds.

So, what did week 15 look like?

Faker

Our first lecture this week was about this fantastic package called Faker. Faker is used to generate test data using methods which allows us to give random values to our database. Some of the types of data we can generate are addresses, names, emails, dates, and more. For a comprehensive list, be sure to check out the documentation here and here.

There are several merits to this with regards to testing. Previously we have used hard coded strings and numbers to create our tests. This limits our tests as bugs might be missed in how our database manages specific values, for example Chinese characters or the Cyrillic alphabet. Issues can also arise from what feel like simple issues, but definitely need consideration, such as people with the last name "Null" often have problems and some names don't fit the default character lengths. Using Faker to generate random data means you can test for these eventualities.

const faker = require('faker');
exports.album = ({ name, artist, year }) => ({
    name: name || faker.random.word(),
    artist: artist || faker.name.findName(),
    year: year || new Date(faker.date.past(30)).getFullYear()
})

Using the music library API project as an example, here we have an album module which has a name and a year. The code is written to either accept the values we give, or to use Faker to generate random data. For name and artist, Faker uses the methods random.word() and name.findName() to generate a random word and a random full name. For date, Faker generates a time stamp with a date from the past 30 years, which is then converted to a JavaScript date object and then we get the year from that object.

Heroku

Heroku is a really handy tool which allows us to deploy our apps. It is a cloud Platform as a Service (PaaS) which hosts web applications. Within the free tier, we can deploy a number of apps and access quite a lot of the features, which is why it is so popular with students and bootcamps. Heroku documentation can be read here, Heroku supports most languages (though it was originally developed for Ruby) and it has a graphical user interface (GUI) and a command line interface (CLI) for deployment. To deploy, we simply add the Heroku app as a remote to an existing Git repository, then use git push to send code to Heroku. Heroku automatically builds the application and creates a new release.

User stories

One of the additions in our next project is the consideration of user stories. User stories are a way to convey requirements to developers, often these will cover the who, the what and the why:

As a [user role] I want to [perform a function] so that [a value is realised].

In the context of our book library project this could look like:

As a [library customer] I want to [create an account with name, email and password] so that I [can view and borrow books] from the library

User stories can help us prioritise what we need to work on and understand the scope of the project. Development driven by stories means that the user needs are fulfilled, giving a quality user experience, representing our understanding of the user needs.

Here's to week 16 of bootcamp!

My Key Take Aways

We building! - At the moment we are constantly building on what we know, breaking things down and adding improvements. Though this can feel like a backwards step sometimes, it also feels developmental. 1% improvement every day or every day can really add up!

Tech is big - This week I went to a great meet up arranged by Manc JS where we heard two fascinating talks. This just reinforced to me how many topics and job roles are covered by the tech sector and how your skills can be applicable. Engaging in these sessions can really help to boost confidence and motivation if you are looking to change careers.