In my react/jest unit test I am trying to call a static method called getSortedAppColumns(), this is part of the component:
static getSortedAppColumns = (appColumns, sortBy, criticalFirst) => {
...
return { id, applications: applicationsSorted, ...rest };
});
};
When I run this test:
it('should sort', () => {
const presets = { presets: { sortCriteria: 'name' } };
const component = (
<AppTrackerContainer applicationStages={applicationStages} {...presets} />
);
const wrapper = shallow(component);
const instance = wrapper.instance();
const appList = applicationStages[0].applications;
expect(instance.getSortedAppColumns(appList)).toMatchSnapshot();
});
Of course I have this error:
TypeError: instance.getSortedAppColumns is not a function 45 | const instance = wrapper.instance(); 46 | const appList = applicationStages[0].applications; > 47 | expect(instance.getSortedAppColumns(appList)).toMatchSnapshot();
Obviously a static method is not an instance but how can I utilise this static call in my jest snapshottest? Need to have a snapshot test that is the bottom line.