theme-tools
theme-tools copied to clipboard
Add ESLint rule to prevent Vitest VS Code extension from blowing up
Is your feature request related to a problem? Please describe.
See https://github.com/Shopify/theme-tools/pull/17 for context on what can go wrong.
TL;DR the Vitest VS Code extension does not support it.each nor tests that have the same name. We should write an ESLint/TSLint rule that prevents folks from committing tests that break the Vitest VS Code extension.
Describe the solution you'd like
-
I would want a rule that warns users against it statements that are taking variables as argument.
e.g.
// bad const testCases = [...] for (const testCase of testCases) { it(`does something for ${testCase.foo}`, () => { //... }); } // also bad it.each(['a', 'b', 'c'])(async (letter) => { // ... }); -
I would want a rule that warns users against tests that have the same name (OK if in different describe blocks, not ok if it's in the same)
e.g.
describe('Parent1:', () => { // ok it('unique', () => {}); // bad, same name at same level it('not-unique', () => {}); it('not-unique', () => {}); }); describe('Parent2:', () => { // ok (since in different describe block) it('unique', () => {}); })