Skip to content

Commit c6e1f66

Browse files
authored
fix vitest (#1444)
* fix vitest * Update patches/@[email protected] * pnpm i * try * fix! * prettier * try * pnpm i * a
1 parent c84b55e commit c6e1f66

File tree

8 files changed

+170
-57
lines changed

8 files changed

+170
-57
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"rimraf": "4.1.2",
4343
"tsx": "3.12.3",
4444
"typescript": "4.9.5",
45-
"vitest": "0.26.3"
45+
"vitest": "0.28.4"
4646
},
4747
"resolutions": {
4848
"graphql": "16.6.0"
@@ -52,7 +52,7 @@
5252
5353
5454
55-
"vitest@0.26.3": "patches/[email protected].patch"
55+
"@vitest/runner@0.28.4": "patches/@[email protected].patch"
5656
}
5757
}
5858
}

packages/plugin/src/testkit.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,7 @@ export class GraphQLRuleTester extends RuleTester {
6868
invalid: GraphQLInvalidTestCase<Options>[];
6969
},
7070
): void {
71-
const ruleTests = Linter.version.startsWith('8')
72-
? tests
73-
: {
74-
valid: tests.valid.map(test => {
75-
if (typeof test === 'string') {
76-
return test;
77-
}
78-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
79-
const { name, ...testCaseOptions } = test;
80-
return testCaseOptions;
81-
}),
82-
invalid: tests.invalid.map(test => {
83-
// ESLint 7 throws an error on CI - Unexpected top-level property "name"
84-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
85-
const { name, ...testCaseOptions } = test;
86-
return testCaseOptions;
87-
}),
88-
};
89-
super.run(ruleId, rule as any, ruleTests);
90-
71+
super.run(ruleId, rule as any, tests);
9172
const linter = new Linter();
9273
linter.defineRule(ruleId, rule as any);
9374

patches/@[email protected]

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# vitest's `--passWithNoTests` flag doesn't work when valid/invalid cases contain empty array 🤷‍
2+
3+
diff --git a/dist/index.js b/dist/index.js
4+
index 14cbb2afd10bc64465281c25dc85a766fa3912ac..22dbf48554fcd2863871dfb003ee194af34532a9 100644
5+
--- a/dist/index.js
6+
+++ b/dist/index.js
7+
@@ -545,9 +545,7 @@ async function runSuite(suite, runner) {
8+
if (!hasTests(suite)) {
9+
suite.result.state = "fail";
10+
if (!suite.result.error) {
11+
- const error = processError(new Error(`No test found in suite ${suite.name}`));
12+
- suite.result.error = error;
13+
- suite.result.errors = [error];
14+
+ suite.result.state = "pass"
15+
}
16+
} else if (hasFailed(suite)) {
17+
suite.result.state = "fail";

patches/[email protected]

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)