Skip to content

Commit ef92af4

Browse files
veritemdsyddall
andauthoredNov 19, 2023
feat(fix): fix previous changes (#294)
* chore: fix typo * feat: add sequential to test function chains * chore(scripts): added script to the repo --------- Co-authored-by: Daniel Syddall <daniel.syddall@in-part.co.uk>
1 parent 06ea81b commit ef92af4

7 files changed

+296
-217
lines changed
 

‎fixtures/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
"vitest": "^0.34.6"
1616
},
1717
"devDependencies": {
18-
"eslint": "^8.53.0"
18+
"eslint": "^8.54.0"
1919
}
2020
}

‎package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@
4242
"devDependencies": {
4343
"@babel/types": "^7.23.3",
4444
"@types/mocha": "^10.0.4",
45-
"@types/node": "^20.9.0",
46-
"@typescript-eslint/eslint-plugin": "^6.10.0",
47-
"@typescript-eslint/rule-tester": "^6.10.0",
45+
"@types/node": "^20.9.2",
46+
"@typescript-eslint/eslint-plugin": "^6.11.0",
47+
"@typescript-eslint/rule-tester": "^6.11.0",
4848
"@veritem/eslint-config": "^0.0.11",
4949
"bumpp": "^9.2.0",
5050
"concurrently": "^8.2.2",
51-
"eslint": "^8.53.0",
52-
"eslint-doc-generator": "^1.5.4",
51+
"eslint": "^8.54.0",
52+
"eslint-doc-generator": "^1.6.1",
5353
"eslint-plugin-eslint-plugin": "^5.1.1",
5454
"eslint-plugin-node": "^11.1.0",
5555
"eslint-plugin-vitest": "^0.3.9",
5656
"eslint-remote-tester": "^3.0.1",
5757
"eslint-remote-tester-repositories": "^1.0.1",
5858
"ts-node": "^10.9.1",
59-
"tsx": "^4.0.0",
60-
"typescript": "^5.2.2",
59+
"tsx": "^4.1.4",
60+
"typescript": "^5.2.0",
6161
"unbuild": "^2.0.0",
6262
"vitest": "^0.34.6"
6363
},
@@ -77,6 +77,6 @@
7777
}
7878
},
7979
"dependencies": {
80-
"@typescript-eslint/utils": "^6.10.0"
80+
"@typescript-eslint/utils": "^6.11.0"
8181
}
82-
}
82+
}

‎pnpm-lock.yaml

+146-207
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎scripts/chain-permutations.mjs

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// imported from https://github.com/veritem/eslint-plugin-vitest/pull/293
2+
// This script generates all possible permutations for vitest methods
3+
import { per } from "percom";
4+
5+
const data = [
6+
{
7+
names: ["beforeEach", "beforeAll", "afterEach", "afterAll"],
8+
first: [],
9+
conditions: [],
10+
methods: [],
11+
last: [],
12+
},
13+
{
14+
names: ["it", "test"],
15+
first: ["extend"],
16+
conditions: ["skipIf", "runIf"],
17+
methods: ["skip", "only", "concurrent", "sequential", "todo", "fails"],
18+
last: ["each"],
19+
},
20+
{
21+
names: ["bench"],
22+
first: [],
23+
conditions: ["skipIf", "runIf"],
24+
methods: ["skip", "only", "todo"],
25+
last: [],
26+
},
27+
{
28+
names: ["describe"],
29+
first: [],
30+
conditions: ["skipIf", "runIf"],
31+
methods: ["skip", "only", "concurrent", "sequential", "shuffle", "todo"],
32+
last: ["each"],
33+
},
34+
];
35+
36+
const DEPTH = 3;
37+
38+
const allPermutations = [];
39+
40+
const join = (methods) => methods.filter((method) => !!method).join(".");
41+
const depths = (maxDepth) => Array.from({ length: maxDepth }, (_, i) => i);
42+
43+
data.forEach((q) => {
44+
q.names.map((name) => {
45+
allPermutations.push(name);
46+
47+
const maxDepth = Math.min(DEPTH, q.methods.length);
48+
const methodPerms = depths(maxDepth).flatMap((i) => [
49+
...per(q.methods, i + 1),
50+
...q.first.flatMap((first) =>
51+
(per(q.methods, i) || [""]).map((p) => [first, ...p])
52+
),
53+
...q.conditions.flatMap((condition) =>
54+
(per(q.methods, i) || [""]).map((p) => [condition, ...p])
55+
),
56+
...q.last.flatMap((last) =>
57+
(per(q.methods, i) || [""]).map((p) => [...p, last])
58+
),
59+
...(i > 0
60+
? q.first.flatMap((first) =>
61+
q.conditions.flatMap((condition) =>
62+
(per(q.methods, i - 1) || [""]).map((p) => [
63+
first,
64+
condition,
65+
...p,
66+
])
67+
)
68+
)
69+
: []),
70+
...(i > 0
71+
? q.first.flatMap((first) =>
72+
q.last.flatMap((last) =>
73+
(per(q.methods, i - 1) || [""]).map((p) => [first, ...p, last])
74+
)
75+
)
76+
: []),
77+
...(i > 0
78+
? q.conditions.flatMap((condition) =>
79+
q.last.flatMap((last) =>
80+
(per(q.methods, i - 1) || [""]).map((p) => [
81+
condition,
82+
...p,
83+
last,
84+
])
85+
)
86+
)
87+
: []),
88+
...(i > 1
89+
? q.first.flatMap((first) =>
90+
q.conditions.flatMap((condition) =>
91+
q.last.flatMap((last) =>
92+
(per(q.methods, i - 2) || [""]).map((p) => [
93+
first,
94+
condition,
95+
...p,
96+
last,
97+
])
98+
)
99+
)
100+
)
101+
: []),
102+
]);
103+
const allPerms = methodPerms.map((p) => [name, ...p].join("."));
104+
allPermutations.push(...allPerms);
105+
});
106+
});
107+
108+
console.log(allPermutations);

‎scripts/package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "scripts",
3+
"version": "0.0.1",
4+
"description": "",
5+
"main": "chain-permutations.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "Verite Mugabo <mugaboverite@gmail.com> (https://veritemugabo.com/)",
11+
"license": "MIT",
12+
"devDependencies": {
13+
"percom": "^1.1.3"
14+
}
15+
}

‎scripts/pnpm-lock.yaml

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/utils/validVitestFnCallChains.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,7 @@ export const ValidVitestFnCallChains = new Set([
10071007
'describe.runIf.todo.each',
10081008

10091009
// Call chains that are not supported by Vitest, but were in the original list
1010+
// TODO(@veritem): Remove the use of these call chains in the test suite
10101011
'xtest',
10111012
'xtest.each',
10121013
'xit',

0 commit comments

Comments
 (0)
Please sign in to comment.