Fixes karma tests. Whatever bundler karma was using was unable to dynamically require files, so this semi-hard-codes the require path for the rules directory. This gives the bundler enough of a hint that it can correctly locate the rules files.
Once this issue was fixed, it became apparent that there was also another, separate issue. The failure handler was trying to determine whether a component had already been rendered or not, but it seems like the logic wasn't quite right. The reporter call was being deferred by after.render, but componentDidMount had already fired. In other words, the failure handler was making the reporter call wait for something that had already happened. This issue could potentially cause some rule violations to never be reported. There were also issues with the way the DOMNode was being located, which was not compatible with react v16, as well as with the way displayName was being generated.
This PR makes a minor change to make a best-effort attempt to locate the DOMNode (adding a new DOMNode location method for react v16) and call the reporter immediately. This will have the potential downside of calling the reporter without a DOMNode if one could not be located (e.g. if the call comes before render), but at the same time it will eliminate the issue of the reporter never being called at all when after.render is called after componentDidMount has already fired.
Fixes karma tests. Whatever bundler karma was using was unable to dynamically require files, so this semi-hard-codes the require path for the rules directory. This gives the bundler enough of a hint that it can correctly locate the rules files.
Once this issue was fixed, it became apparent that there was also another, separate issue. The failure handler was trying to determine whether a component had already been rendered or not, but it seems like the logic wasn't quite right. The reporter call was being deferred by
after.render
, butcomponentDidMount
had already fired. In other words, the failure handler was making the reporter call wait for something that had already happened. This issue could potentially cause some rule violations to never be reported. There were also issues with the way the DOMNode was being located, which was not compatible with react v16, as well as with the waydisplayName
was being generated.This PR makes a minor change to make a best-effort attempt to locate the DOMNode (adding a new DOMNode location method for react v16) and call the reporter immediately. This will have the potential downside of calling the reporter without a DOMNode if one could not be located (e.g. if the call comes before render), but at the same time it will eliminate the issue of the reporter never being called at all when
after.render
is called aftercomponentDidMount
has already fired.