├── README.md ├── components └── Button.jsx ├── .gitignore ├── package.json ├── tests └── index.js └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # react-tape-testing 2 | [![devDependency Status](https://david-dm.org/Gattermeier/react-tape-testing/dev-status.svg)](https://david-dm.org/Gattermeier/react-tape-testing#info=devDependencies) 3 | 4 | Unit testing React components with Tape in ES6 5 | -------------------------------------------------------------------------------- /components/Button.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import React from 'react'; 4 | 5 | class Button extends React.Component { 6 | static propTypes = { 7 | label: React.PropTypes.string, 8 | className: React.PropTypes.string 9 | } 10 | static defaultProps = { 11 | label: 'button', 12 | className: 'default-class' 13 | } 14 | constructor(props) { 15 | super(props) 16 | } 17 | render() { 18 | return ( 19 |
20 | {this.props.label} 21 |
22 | ) 23 | } 24 | } 25 | export default Button 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-tape", 3 | "version": "1.0.0", 4 | "babel": { 5 | "presets": [ 6 | "es2015", 7 | "react", 8 | "stage-0" 9 | ] 10 | }, 11 | "description": "Unit testing React components with Tape in ES6", 12 | "scripts": { 13 | "test": "babel-tape-runner tests/**/*.js | faucet" 14 | }, 15 | "keywords": [ 16 | "tape", 17 | "react", 18 | "unit", 19 | "test", 20 | "testing" 21 | ], 22 | "author": "Matthias Gattermeier", 23 | "devDependencies": { 24 | "babel-core": "^6.3.17", 25 | "babel-preset-es2015": "^6.3.13", 26 | "babel-preset-react": "^6.3.13", 27 | "babel-preset-stage-0": "^6.3.13", 28 | "babel-tape-runner": "^2.0.0", 29 | "extend-tape": "^1.1.0", 30 | "faucet": "0.0.1", 31 | "react": "^0.14.3", 32 | "react-addons-test-utils": "^0.14.3", 33 | "react-unit": "^1.1.1", 34 | "tape": "^4.2.2", 35 | "tape-jsx-equals": "^1.0.0" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { createRenderer } from 'react-addons-test-utils'; 3 | import createComponent from 'react-unit'; 4 | import tape from 'tape'; 5 | import addAssertions from 'extend-tape'; 6 | import jsxEquals from 'tape-jsx-equals'; 7 | const test = addAssertions(tape, {jsxEquals}); 8 | 9 | // Component to test 10 | import Button from '../components/Button'; 11 | 12 | test('----- React Component Tests: Button -----', (t) => { 13 | 14 | // Shallow rendering: Render React element only *one* level deep 15 | const component = createComponent.shallow(