Skip to content

Instantly share code, notes, and snippets.

View vjwilson's full-sized avatar

Van Wilson vjwilson

View GitHub Profile
@vjwilson
vjwilson / README.md
Created September 21, 2017 16:01
Preparing for TDD with React

Preparing for TDD with React

If you want to follow along with the live coding examples, it's best to have the following already installed before you come to this talk.

  • Node (version 6, use nvm if you need to keep multiple versions Node)
  • npm (comes with Node), or yarn, if you prefer that
  • create-react-app CLI npm install -g create-react-app
  • Your favorite text editor
  • git, if you want to pull the sample repo, and check out the starting code for each part of the talk
@vjwilson
vjwilson / 7-1-write-linkshare-function-tests
Created September 20, 2017 00:54
Feature and Step Definitions specific to Linkshare
# same packages
# same world.js
# same hooks.js
# new .feature file
# new browser_steps.js
@vjwilson
vjwilson / 6-1-setup-cucumber.js
Created September 20, 2017 00:42
Setup Cucumber.js for functional testing
# add libraries
npm install --save-dev chromedriver cucumber selenium-webdriver
# add support file
touch features/support/world.js
# add hooks file
touch features/step_definitions/hooks.js
# add feature file
@vjwilson
vjwilson / 5-1-add-redux-with-tests
Created September 20, 2017 00:34
Redux testing
# add Redux-specific files and tests
# Actions
touch src/actions/actionTypes.js
touch src/actions/linkActions.test.js
touch src/actions/linkActions.js
# Reducers
touch src/reducers/index.js
touch src/reducers/linkReducer.test.js
# edit App component tests
touch src/components/App/App.test.js
# edit App component
touch src/components/App/App.js
# edit LinkItem component tests
touch src/components/LinkItem/LinkItem.test.js
# edit LinkItem component
@vjwilson
vjwilson / 2-1-add-link-item.sh
Last active September 20, 2017 00:21
Add your first TDD tests, and then your first component
@vjwilson
vjwilson / 1-clone-repo.sh
Last active September 17, 2017 17:23
Snippets for practicing TDD on the Linkshare app, part 1
# 1. fork the repo into your own GitHub account
# then,
git clone <URL of your fork>
# 2. checkout the first tag
git checkout 1-start-with-create-react-app
@vjwilson
vjwilson / buttons.jsx
Created June 3, 2017 14:36
Two alternatives for wrapping a button element in a React component
// Option 1, more like HTML button
class PrimaryButton extends React.Component {
render() {
return (
<button onClick={this.props.action}>{this.props.children}</button>
);
}
}
// Option 1 usage
@vjwilson
vjwilson / components.md
Last active May 31, 2017 00:29
Sample basic Catalog styleguide

Components

Recipe Component

The Recipe component takes a recipe object, and if it is in a list, also a key prop.

lang: jsx
---