Skip to content

Instantly share code, notes, and snippets.

@jtorreggiani
jtorreggiani / Todos.js
Created March 2, 2019 00:44
Basic todos page
import React, { Component } from 'react'
const todosUrl = 'http://localhost:3001/todos'
function Todo ({ number, todo }) {
return (
<li>{number}. { todo.title }</li>
)
}
@jtorreggiani
jtorreggiani / headingtext.spec.js
Last active March 1, 2019 23:51
Introduction test assertion
it('has introduction text', async () => {
// Use the browser selector method to get the heading
// See docs for details https://webdriver.io/docs/selectors.html
const paragraph = await browser.$('p')
await expect(paragraph.getText()).resolves.toEqual('Edit src/App.js and save to reload.')
})
@jtorreggiani
jtorreggiani / navigation.spec.js
Last active March 1, 2019 22:57
Navigation tests
it('navigates to todos page on link click', async () => {
const link = await browser.$('=Todos')
await link.click()
const heading = await browser.$('h1')
await expect(browser.getUrl()).resolves.toEqual(`${baseUrl}/todos`)
await expect(heading.getText()).resolves.toEqual('Todos')
})
it('navigates to about page on link click', async () => {
@jtorreggiani
jtorreggiani / links.spec.js
Last active March 1, 2019 22:52
Assert existence of links
@jtorreggiani
jtorreggiani / homepagetext.spec.js
Last active March 1, 2019 22:51
Updated assertion
it('has home page text', async () => {
const heading = await browser.$('h1')
await expect(heading.getText()).resolves.toEqual('Home')
})
@jtorreggiani
jtorreggiani / App.integration.test.js
Last active March 1, 2019 22:51
Integration test boilerplate code
// Import the remote function from webdriver
import { remote } from 'webdriverio'
// Describe a basic scenario
describe('User visits home page', () => {
// Define a browser variable to be available to each
// assertion that will be declared below
let browser
// Before all the assertions we set up the browser object
// The default configuration for webdriver is async mode,
// so we will need to be defined our specs as async functions.
@jtorreggiani
jtorreggiani / App.css
Last active March 1, 2019 22:19
Super basic app styles
.App-nav {
display: flex;
flex-direction: row;
padding: 5px;
}
.App-nav > a {
flex: 1 1 auto;
text-align: center;
padding:0 15px;
@jtorreggiani
jtorreggiani / App.js
Created March 1, 2019 22:13
Basic React Router app
import React from 'react'
import './App.css'
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
function Home () {
return (
<div>
<h1>Home</h1>
</div>
)
@jtorreggiani
jtorreggiani / app.yml
Last active February 26, 2019 00:38
app.yml
entrypoint: bundle exec rackup --port $PORT
env: flex
runtime: ruby
env_variables:
SECRET_KEY_BASE: SECRET_BASE
beta_settings:
cloud_sql_instances: skeleton-application-12345:us-west2:skeleton-application-cloudsql-instance
@jtorreggiani
jtorreggiani / database.yml
Created February 26, 2019 00:15
config/database.yml
production:
<<: *default
username: deploy
password: [PASSWORD]
database: skeleton_application_production
socket: "/cloudsql/skeleton-application-12345:us-west2:skeleton-application-cloudsql-instance"