Testing Tips

When building ReGraph into your applications, you may be interested in automated integration testing. ReGraph has a number of helpful APIs available to give you information about the items in the chart.

Chart events

The onUpdateComplete event is invoked each time the chart has finished updating. Use this event e.g. to check when the chart animation is complete. This event is also suitable for production.

Chart instance methods

The following functions, currently all in beta, are particularly useful for use in integration tests. To use them, give access to the chart by exposing your chart's ref on the window:

const MyFunctionalComponent = (props) => {
  const { items } = props;

  const chartRef = React.useRef(null);

  // expose the ref on the top-most window
  window.top.chart = chartRef

  return (
    <Chart
      ref={chartRef}
      items={items}
    />
  );
};

Then you can use them in your tests:

const item = window.chart.current.getItemInfo('node1');

See also Instance Methods for more information.

getItemAtViewCoordinates

The getItemAtViewCoordinates instance method returns an object with information about the item or sub-item at the specified view coordinates.

getItemInfo

The getItemInfo instance method returns a list of all chart items, or details of a specified item if a valid id is passed.

getViewCoordinatesOfItem

The getViewCoordinatesOfItem instance method returns an object with view coordinates of the specified item or sub-item.

Terms of use

These terms do not alter or supersede any existing agreements between you (or your employer) and us.

By accessing or using any Content you agree to be bound by these Terms of Use. Please review these terms carefully before using the website.

The contents of this website, including but not limited to any text, code samples, API references, schemas, interactive tools, and other materials (collectively, the 'Content'), are made available for informational and internal evaluation purposes only. All intellectual property rights in the Content are reserved. No licence is granted to use the Content for any commercial purpose, or to copy, distribute, modify, reverse-engineer, or incorporate any part of the Content into any product or service, without our prior written consent.

This Content is provided “as is” and “as available,” without any representations, warranties, or guarantees of any kind, whether express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, non-infringement, or accuracy. To the fullest extent permitted by applicable law, we expressly exclude and disclaim all implied warranties, conditions, and other terms that might otherwise be implied.

We disclaim all liability for any loss or damage, whether direct, indirect, incidental, consequential, or otherwise, arising from any reliance placed on the Content or from your use of it, to the fullest extent permitted by applicable law. By continuing to access or use the Content, you acknowledge and agree to these terms.