Skip to content

Instantly share code, notes, and snippets.

Paul pablopaul

View GitHub Profile
View redux-store.js
import { createStore } from 'redux';
// reducer is the reducer we defined earlier
const store = createStore(reducer);
View redux-store-dispatch-action.js
store.dispatch(
{
type: 'CHARACTER_TYPED',
char: 'x'
}
);
View redux-store-getstate.js
const state = store.getState();
// Logs 'x'
console.log(state);
View redux-store-subscribe.js
const unsubscribe = store.subscribe( () => console.log( store.getState() ) );
View redux-store-subscriber-demo.js
// Logs 'x'
store.dispatch(insertCharacter('x'));
// Logs 'xy'
store.dispatch(insertCharacter('y'));
// `removeCharacter` is an action creator wrapping the `BACKSPACE` action
// Logs 'x'
store.dispatch(removeCharacter());
// Logs ''
store.dispatch(removeCharacter());
View redux-store-unsubscribe.js
unsubscribe();
// Nothing is logged
store.dispatch(insertCharacter('z'));
@pablopaul
pablopaul / testing-react-components.js
Last active Apr 18, 2018 — forked from peduarte/testing-react-components.txt
Fix "ReferenceError: document is not defined" in jsdom + enzyme + ava environment.
View testing-react-components.js
/*
* Step 1
*/
npm install --save-dev jsdom
/*
* Step 2 (http://airbnb.io/enzyme/docs/guides/jsdom.html)
*
* test-browser-env.js
@pablopaul
pablopaul / codecept.conf.js
Last active Nov 26, 2018
CodeceptJS 1.4.6. Debug White Page Failure - To see the logged page source run your tests with "--verbose"
View codecept.conf.js
// Add the plugin to the CodeceptJS config
...
plugins: {
logPageSource: {
require: "./logPageSource",
enabled: true
}
}
You can’t perform that action at this time.