lundi 19 avril 2021

jest/enzym expect.any(ReactComponent)

may be some of you faced with testing features when need to check specification. I am faced with want to test files of themes which look like some thing like this.

export { ReactComponent as SVG1 } from './svg1.svg';
export { ReactComponent as SVG2 } from './svg2.svg';
// ... etc

I was find the way how to check... But it doesn't provide 100% sure it's will be React Component.

const ReactComponent = expect.any(Function);

const svgSchema = expect.objectContaining({
  SVG1: ReactComponent,
  SVG2: ReactComponent,
});

May be some who knows how to define more smart/elegant solution ?

P.S. I do not want to test @svgr/webpack functionality. Within project will be a lot of different themes and i want to make sure they contain required SVG for each theme

Aucun commentaire:

Enregistrer un commentaire