Skip to content

Commit f39985c

Browse files
committed
Only run tests that the current graphql version supports
1 parent 2d8277b commit f39985c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

__tests__/index.test.mjs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
// @ts-check
22

3-
import { test } from "node:test";
43
import * as assert from "node:assert";
5-
import { semanticToStrict, semanticToNullable } from "../dist/index.js";
6-
import { buildSchema, printSchema } from "graphql";
74
import { readdir, readFile } from "node:fs/promises";
5+
import { test } from "node:test";
6+
7+
import * as graphql from "graphql";
8+
9+
import { semanticToNullable, semanticToStrict } from "../dist/index.js";
10+
11+
const { buildSchema, printSchema } = graphql;
12+
13+
const isSemanticNonNullType = /** @type {any} */ (graphql)
14+
.isSemanticNonNullType;
815

916
const TEST_DIR = import.meta.dirname;
1017
const files = await readdir(TEST_DIR);
18+
const skip = test.skip.bind(test);
1119

1220
for (const file of files) {
1321
if (file.endsWith(".test.graphql") && !file.startsWith(".")) {
14-
test(file.replace(/\.test\.graphql$/, ""), async () => {
22+
const pureDirective = file === "schema-with-directive-only.test.graphql";
23+
const maybeTest =
24+
pureDirective || isSemanticNonNullType != null ? test : skip;
25+
maybeTest(file.replace(/\.test\.graphql$/, ""), async () => {
1526
const sdl = await readFile(TEST_DIR + "/" + file, "utf8");
1627
const schema = buildSchema(sdl);
1728
await test("semantic-to-strict", async () => {

0 commit comments

Comments
 (0)