Last active
October 21, 2023 14:37
-
-
Save KoenBrouwer/e1df9ff68d0a3fc2d98f34a1d23f41a6 to your computer and use it in GitHub Desktop.
Revisions
-
KoenBrouwer revised this gist
Oct 21, 2023 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ // 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"); -
KoenBrouwer created this gist
Oct 21, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ 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);