Posts

Showing posts from 2019

JAM stack: Deploying a S3 website form commandline.

Image
Hosting the client facing page is an important part of creating a performant JAM stack app, To do this I will be using Amazon's AWS S3 offering and the AWS CLI. From here I will assume that you have the AWS CLI installed and have it configured to use an account that is capable of creating and configuring S3 buckets. I'm using Powershell emulated through cmndr on Windows as my command line. Create the bucket The first thing we need is to create the bucket. If every thing is fine it will look like this.  (replace kleeut-jamblog with your bucket name, they need to be unique) aws s3api create-bucket --acl public-read --bucket kleeut-jamblog --create-bucket-configuration LocationConstraint=ap-southeast-2 { "Location": "http://kleeut-jamblog.s3.amazonaws.com/" } Gotchas: The error messages are pretty good, these are the ones I've commonly run into. If you're already run the command or for you own the bucket you'll see: An

100% code coverage is false safety

Image
It is really easy to lie to yourself when doing Test Driven Development that your code is good, safe, predictable and well understood, just because you have that magic 100% code coverage number. If you test just the happy case it is easy to get to 100% code coverage, while still leaving code paths untested and unexpected behaviour unexplored. Consider this simple function that takes in an object with 2 properties, an array of strings and a separating string to concatenate between them. 1: export const concatStrings = ({ strings, joiner }) => { 2: return strings.join(joiner); 3: }; Testing the Happy Path is really easy. 1: import { concatStrings } from "./stringConcat"; 2: describe(concatStrings, () => { 3: it("Should concatinate strings", () => { 4: const actual = concatStrings({ joiner: ", ", strings: ["one", "two"] }); 5: expect(actual).toBe("one, two"); 6: });