Skip to content

Instantly share code, notes, and snippets.

View paulbjensen's full-sized avatar

Paul Jensen paulbjensen

View GitHub Profile
@paulbjensen
paulbjensen / api_index.js
Created June 18, 2018 09:06
The API repo's index.js file, part of an article on Medium.
'use strict';
/*eslint no-console: ["error", { allow: ["log"] }] */
// Dependencies
const express = require('express');
const Raven = require('raven');
const { port, allowedOrigins, sentryDSN } = require('./config');
Raven.config(sentryDSN).install();
const httpShutdown = require('http-shutdown');
const bodyParser = require('body-parser');
@paulbjensen
paulbjensen / web_index.js
Created June 18, 2018 08:52
The index.js file for the web repo, part of an article on Medium
// This is used to serve the app for integration tests with the API via Cucumber
/*eslint no-console: ["error", { allow: ["log"] }] */
// Dependencies
//
const express = require('express');
const httpShutdown = require('http-shutdown');
const path = require('path');
const app = express();
const config = require('./config');
@paulbjensen
paulbjensen / hooks_v1.js
Last active June 18, 2018 08:26
The hooks.js file for Cucumber, part of an article on Medium
// Dependencies
const { After, Before, AfterAll } = require('cucumber');
const scope = require('./support/scope');
Before(async () => {
// You can clean up database models here
});
After(async () => {
// Here we check if a scenario has instantiated a browser and a current page
@paulbjensen
paulbjensen / world_v1.js
Created June 18, 2018 07:29
The world.js file for a
// Dependencies
const { setWorldConstructor } = require('cucumber');
const puppeteer = require('puppeteer');
const scope = require('./support/scope');
const World = function() {
scope.driver = puppeteer;
};
setWorldConstructor(World);
@paulbjensen
paulbjensen / puppeteer_example.js
Created June 18, 2018 05:37
An example of using Puppeteer, for an article on Medium
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://google.co.uk');
await page.screenshot({path: 'google.co.uk.png'});
await browser.close();
})();
@paulbjensen
paulbjensen / cucumber_output_v2.txt
Created June 17, 2018 18:45
The output from running npm Cucumber at this stage, for a Medium article
P--------
Warnings:
1) Scenario: Successfully delete my data # features/delete_my_data.feature:6
? Given I am a registered user # features/step_definitions/example_steps.js:3
Pending
- When I login to the application # features/step_definitions/example_steps.js:8
- And I visit my settings # features/step_definitions/example_steps.js:13
- When I click on "Delete my data" # features/step_definitions/example_steps.js:18
@paulbjensen
paulbjensen / example_steps.js
Created June 17, 2018 18:33
An example step definitions file for a Medium article
const { Given, When, Then } = require('cucumber');
Given('I am a registered user', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
When('I login to the application', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
@paulbjensen
paulbjensen / cucumber_output_v1.txt
Created June 17, 2018 12:38
The output from running a cucumber-js command, part of a Medium article
UUUUUUUUU
Warnings:
1) Scenario: Successfully delete my data # features/delete_my_data.feature:6
? Given I am a registered user
Undefined. Implement with the following snippet:
Given('I am a registered user', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
@paulbjensen
paulbjensen / delete_my_data_v2.feature
Created June 17, 2018 11:15
A Cucumber feature file for a Medium article
Feature: Delete my data
In order to no longer have any of my data stored on the application
As a registered user
I want to be able to delete my data from the application
Scenario: Successfully delete my data
Given I am a registered user
When I login to the application
And I visit my settings
When I click on "Delete my data"
@paulbjensen
paulbjensen / delete_my_data_v1.feature
Last active June 17, 2018 10:45
A Cucumber feature file for a medium article
Feature: Delete my data
In order to no longer have any of my data stored on the application
As a registered user
I want to be able to delete my data from the application