Skip to content

Instantly share code, notes, and snippets.

@busypeoples
busypeoples / AngularJS-ES6-Test-Skeleton
Last active June 6, 2020 01:29
AngularJS - Karma, Jasmine, Browserify, Stringify - ES6 Test Setup
We couldn’t find that file to show.
@busypeoples
busypeoples / package.json
Last active December 20, 2017 13:37
Testing in React: Basic Examples + Setup
{
"name": "example-karma-jasmine-webapck-test-setup",
"description": "React Test Setup with Karma/Jasmine/Webpack",
"scripts": {
"test": "karma start --single-run --browsers PhantomJS"
},
"devDependencies": {
"babel": "^6.5.2",
"babel-core": "^6.5.2",
"babel-eslint": "^5.0.0",
@busypeoples
busypeoples / package.json
Last active May 6, 2016 15:03
Webpack / Karma / Jasmine package.json example
{
"name": "example-karma-jasmine-webapck-test-setup",
"description": "React Test Setup with Karma/Jasmine/Webpack",
"scripts": {
"test": "karma start --single-run --browsers PhantomJS"
},
"devDependencies": {
"babel": "^6.5.2",
"babel-core": "^6.5.2",
"babel-eslint": "^5.0.0",
import React from 'react'
import { shallow, mount, render } from 'enzyme'
import Root, { SearchBar, ReleaseTable, Release } from '../src/Root'
const createShallowRelease = (outOfPrint = true) => {
let props = {release: { artist: 'foobar', title: 'bar', outOfPrint }};
return shallow(<Release {...props} />);
};
describe('<Release>', () => {
import React from 'react'
import { shallow, mount, render } from 'enzyme'
import Root, { SearchBar, ReleaseTable, Release } from '../src/Root'
const createShallowRelaseTable = (noOutOfPrint = false, searchText = '') => {
let items = [{ artist: 'foobar', title: 'bar', outOfPrint: true }];
let props = { searchText, releases: items, noOutOfPrint };
return shallow(<ReleaseTable { ...props } />);
}
import React from 'react'
import { shallow, mount, render } from 'enzyme'
import Root, { SearchBar, ReleaseTable, Release } from '../src/Root'
describe('<SearchBar>', () => {
let onSearch;
beforeEach(() => {
onSearch = jasmine.createSpy('onSearch');
});
@busypeoples
busypeoples / SomeComponent.js
Created May 8, 2016 21:45
Devcards for React - initial ideas
import React, { PropTypes } from 'react';
const foobar = (props) => (
<div>
<h3>Testdrive. Stateless. Yes.</h3>
<div>{props.name}</div>
<div>{props.model}</div>
</div>
);
@busypeoples
busypeoples / DevCardsIndex.js
Last active May 12, 2016 21:42
Devcards for React - initial ideas
import React, { PropTypes, Component } from 'react';
import { createStore, combineReducers } from 'redux';
import { render } from 'react-dom';
let devCardTest = require('./DevCardsTest.js').default;
const devCardStyle = {
background: '#eee',
padding: '20px',
marginBottom: '10px'
};
@busypeoples
busypeoples / TestSetupExampleCRAEnzymeChaiMocka.md
Last active May 13, 2019 13:07
Mocha/Chai/Enyzme test setup with create-react-app

Basic setup for using Enzyme/Mocha/Chai with create-react-app

This is a temporary solution. Might change in the near future, this depends on how create-react-app will implement testing.

create-react-app quick-test-example

cd quick-test-example

npm run eject
import React from 'react'
import { render } from 'react-dom'
import { compose, map, prop, curry, reduce, pipe } from 'ramda'
const combine = curry((c, o) => x => (<div>{c(x)} {o(x)}</div>))
const combineComponents = (...args) => {
const [first, ...rest] = args
return reduce((acc, c) => combine(acc, c), first, rest)
}