// This script creates a list of all possible permutations of call chains based on the Vitest Test API Reference (https://vitest.dev/api/). // I used this to improve a package called veritem/eslint-plugin-vitest. // For further context see: https://github.com/veritem/eslint-plugin-vitest/issues/275. const fs = require("fs"); const percom = require("percom"); const data = [ { names: ["beforeEach", "beforeAll", "afterEach", "afterAll"], methods: [], }, { names: ["it", "test"], methods: ["extend", "skip", "skipIf", "runIf", "only", "concurrent", "todo", "fails", "each"], }, { names: ["bench"], methods: ["skip", "only", "todo"], }, { names: ["describe"], methods: ["skip", "skipIf", "only", "concurrent", "sequential", "shuffle", "todo", "each"], }, ]; const DEPTH = 3; const allPermutations = []; data.forEach((q) => { q.names.map((name) => { allPermutations.push(name); const maxDepth = Math.min(DEPTH, q.methods.length); for (let i = 0; i < maxDepth; i++) { const perms = percom.com(q.methods, i + 1); const allPerms = perms.map((p) => [name, ...p].join(".")); allPermutations.push(...allPerms); } }); }); console.log(allPermutations);