react-shallowdom-helpers
How to install
npm install --save-dev react-shallowdom-helpers
Helpers
render
; const renderedComponent = ShallowDOMHelpers;
reRender
let renderedComponent = ShallowDOMHelpers; ShallowDOMHelpers; renderedComponent = ShallowDOMHelpers; // latest state is now set in the component
getMountedInstance
Return the current mounted instance. You have access to properties such as state in this object.
ShallowDOMHelpers;
findAllByClass
It returns an array containing all the matching elements. If no element is found an empty array is returned.
ShallowDOMHelpers;
findByClass
It returns the first element matching the class name.
ShallowDOMHelpers;
findAllByTag
It returns an array containing all the matching elements. If no element is found an empty array is returned.
ShallowDOMHelpers;
findByTag
It returns the first element matching the tag.
ShallowDOMHelpers;
findById
It returns the first element matching the id.
ShallowDOMHelpers;
getInnerChildren
ShallowDOMHelpers; const innerChildren = ShallowDOMHelpers; // Inner Children
getTextByClass(renderedComponent, 'class-name-here');
const text = ShallowDOMHelpers; to;
getTextById
const text = ShallowDOMHelpers; to;
getTextByTag
const text = ShallowDOMHelpers; to;
click
// by class name ShallowDOMHelpers; // by id ShallowDOMHelpers; // by tag ShallowDOMHelpers;
change
// by class name ShallowDOMHelpers; // by id ShallowDOMHelpers; // by tag ShallowDOMHelpers;
TestUtils
Return React's TestUtils.
ShallowDOMHelpersTestUtils;
Contributing
Create a fork of the project. Add the functionality you want as well as tests and submit a PR.
How to run the tests
nvm use 5 npm install npm test
TODO
- Simulate event payload when an event is trigger. (i.e Synthetic event)
- Add more matchers
- Refactor, refactor, refactor