3.2.0 • Published 5 years ago

ku4es-react-testing v3.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Classes

Functions

Context

Kind: global class

new Context(props)

Param
props

context.$render() ⇒ XML

Dependent classes can override this virtual $render method to create situations where they can do such things as updateChildProps on the fly to gain test coverage for such a scenario. To gain such coverage one can override this method and return the target component passing to it this.state. For example:

$render() { return <MyComponent { ...this.state }/> }

Kind: instance method of Context
Access: protected

context.updateChildProps(value)

This method exposes a entry point for a pattern that enables dependent tests to obtain test coverage for those cases where system components require testing of prop value updates during the course of their lifecycle. To leverage this pattern successfully the developer will need to extend this Context class and override the $render method such that it returns their target, prop-updating component after passing this.state into the target component. For example: return(<MyComponent {...this.state}/>)

Kind: instance method of Context
Access: public

ParamDescription
valueObject literal of new props

context.rerender()

Exposes an expressive means to perform a rerendering of a this Context.

Kind: instance method of Context
Access: public

context.destroy()

Clean up this component and cover unmount

Kind: instance method of Context
Access: public

loadDom(markup, config)

Loads a fully functional, unsecure, in-memory headless DOM. Note that you should only load this DOM if you know what you are loading into it, and what your test will be executing. This DOM can load external images and will run script. This does expose the ability for malicious code to potentially access your OS through Node.

Kind: global function

ParamTypeDescription
markupstringOptional initialization markup.
configObjectJSDom configuration options.

loadSafeDom(markup, config)

Load a secure in-memory headless DOM. Note that there are no security guarantees with this DOM, though it does not allow for image loading or running scripts, negating these avenues as potential attack vectors for malicious code.

Kind: global function

ParamTypeDescription
markupstringOptional initialization markup.
configObjectJSDom configuration options.

unloadDom()

Unloads a DOM loaded with loadDom or loadSafeDom

Kind: global function

renderComponent(component) ⇒ function

Renders a component into a DOM loaded with loadDom or loadSafeDom

Kind: global function
Returns: function - - Function that returns a jQuery style selection result augmented with a local member component that returns a pointer to the rendered Component.

ParamTypeDescription
componentComponentA React Component to test, e.g.