Skip to content

Instantly share code, notes, and snippets.

View alvinslee's full-sized avatar

Alvin Lee alvinslee

View GitHub Profile
@alvinslee
alvinslee / test-1x.md
Created January 26, 2016 03:10
Test interface in Cucumber 1 Time Only

Test the interface 1 time only

There were examples in our Cucumber tests where the first scenario test really seemed to be testing that the interface does what it was supposed to, while all subsequent tests were simply checks that the controller did what it was supposed to when given different POST data. This causes a lot of overhead. For example:

Scenario: Signing up a new user creates guest account and sends invitation email

Given I am on the sign up page
When I enter "John" as the first name for the new user
And I enter "Smith" as the last name for the new user
@alvinslee
alvinslee / 0_reuse_code.js
Created June 20, 2016 01:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@alvinslee
alvinslee / prepare-test-data.js
Last active February 4, 2021 17:38
A module for test data preparation, filled with code duplication
const {
addTimestamps,
truncateLocations
} = require('./testHelpers')
const userData = require('./testData/userData.json')
const deviceTypes = require('./testData/deviceTypes.json')
const nutritionPlans = require('./testData/nutritionPlans.json')
const exerciseRoutine = require('./testData/exerciseRoutine.json')
const goals = require('./testData/goals.json')
@alvinslee
alvinslee / prepare-test-data-02.js
Created February 4, 2021 17:39
A module for preparing test data - top of file, moving into a results object
const result = {
userData: require('./testData/userData.json'),
deviceTypes: require('./testData/deviceTypes.json'),
nutritionPlans: require('./testData/nutritionPlans.json'),
exerciseRoutine: require('./testData/exerciseRoutine.json'),
goals: require('./testData/goals.json'),
miniChallenges: require('./testData/miniChallenges.json'),
rewards: require('./testData/rewards.json')
}
@alvinslee
alvinslee / prepare-test-data-03.js
Last active February 4, 2021 17:41
A module for preparing test data - loading result object via a for loop
const KEYS = [
'userData',
'deviceTypes',
'nutritionPlans',
'exerciseRoutine',
'goals',
'miniChallenges',
'rewards'
]
@alvinslee
alvinslee / prepare-test-data-04.js
Created February 4, 2021 17:42
A module for preparing test data - with code duplication removed
const {
addTimestamps,
truncateLocations
} = require('./testHelpers')
const KEYS = [
'userData',
'deviceTypes',
'nutritionPlans',
'exerciseRoutine',
@alvinslee
alvinslee / localhost.ext
Last active February 5, 2021 20:15
configuration for localhost SSL certificate
authorityKeyIdentifier = keyid,issuer
basicConstraints = CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
IP.1 = 127.0.0.1
@alvinslee
alvinslee / index.js
Last active February 5, 2021 21:19
Node.js Express Server served with HTTPS using localhost certificate
const fs = require('fs')
const key = fs.readFileSync('./localhost/localhost.decrypted.key')
const cert = fs.readFileSync('./localhost/localhost.crt')
const express = require('express')
const app = express()
app.get('/', (req, res, next) => {
res.status(200).send('Hello world!')
})
@alvinslee
alvinslee / server.js
Created August 5, 2021 16:47
Insomnia+GraphQL - server.js
const users = [
{
id: 1,
name: "Francis",
email: "franny@ha.com",
addresses: [
{
street: "1644 Melrose Place",
city: "Los Angeles",
country: "USA",
@alvinslee
alvinslee / schema.graphql
Created August 5, 2021 16:47
Insomnia+GraphQL - schema.graphql
type User {
id: Int!
name: String!
email: String!
addresses: [Address]
}
type Address {
street: String!
city: String!