diff --git a/.changeset/stupid-gorillas-punch.md b/.changeset/stupid-gorillas-punch.md new file mode 100644 index 00000000000..d93d58ffc1d --- /dev/null +++ b/.changeset/stupid-gorillas-punch.md @@ -0,0 +1,5 @@ +--- +'@shopify/polaris-icons': patch +--- + +Added better error documentation on icon validation diff --git a/polaris-icons/tests/validate-svg-content.test.js b/polaris-icons/tests/validate-svg-content.test.js index 2a635e6a368..9cede5fcdb8 100644 --- a/polaris-icons/tests/validate-svg-content.test.js +++ b/polaris-icons/tests/validate-svg-content.test.js @@ -21,16 +21,20 @@ const allIconFiles = globby const iconSource = fs.readFileSync(absoluteIconPath, 'utf-8'); - const {viewbox, colors} = configPerSet.get([set].filter(Boolean).join('_')); - + const svg = configPerSet.get([set].filter(Boolean).join('_')); + if (svg == null) { + throw new Error( + `SVG config not found for ${absoluteIconPath}. Make sure your icon contains "Major" or "Minor" in its name.`, + ); + } return { iconPath: path.relative(path.join(__dirname, '..'), absoluteIconPath), iconSource, iconAst: unified() .use(parse, {fragment: true, space: 'svg'}) .parse(iconSource), - expectedViewbox: viewbox, - expectedFillColors: colors, + expectedViewbox: svg.viewbox, + expectedFillColors: svg.colors, }; });