Skip to content

Commit fe74a18

Browse files
authored
chore: use gqltest.runtests (#58)
1 parent e126d48 commit fe74a18

File tree

3 files changed

+20
-57
lines changed

3 files changed

+20
-57
lines changed

tests/gqltest.js

Lines changed: 17 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ const { URL } = require("url");
44
const path = require("node:path");
55

66
const {
7-
executeOK,
8-
logOnFail,
9-
} = require('gqltest/packages/gqltest/gqltest.js')
7+
runtests,
8+
} = require('gqltest/packages/gqltest/gqltest.js');
109

11-
const stepzen = require('gqltest/packages/gqltest/stepzen.js');
10+
const stepzen = require("gqltest/packages/gqltest/stepzen.js");
1211

1312
const endpoint = process.env.STEPZEN_ENDPOINT;
1413

@@ -31,58 +30,23 @@ function deployEndpoint(endpoint, dirname) {
3130
console.log(stdout);
3231
}
3332

34-
// Runs a GraphQL request against the endpoint
35-
// as a test returning the response.
36-
// The test will fail if the request does not
37-
// have status 200 or has any GraphQL errors.
38-
async function runGqlOk(endpoint, headers, request, expected) {
39-
await executeOK({
40-
test: this,
41-
endpoint,
42-
headers: headers,
43-
request,
44-
expected,
45-
})
46-
}
47-
4833
// deploys graphql schema located in dirname to the test endpoint provided by the environment (process.env.STEPZEN_ENDPOINT),
4934
// and then runs through all fo the field selection tests.
5035
function deployAndRun(dirname, tests, headers) {
51-
it("deploy", function () {
52-
// deployEndpoint will try up to three times to deploy
53-
// the schema with a backoff that can total four seconds.
54-
// So set the timeout to be (3*10)+4 seconds to cover a worst case scenario.
55-
this.timeout(34000);
56-
return deployEndpoint(endpoint, dirname);
36+
describe("deployAndRun", function () {
37+
this.timeout(10000);
38+
this.slow(1000);
39+
it("deploy", function () {
40+
// deployEndpoint will try up to three times to deploy
41+
// the schema with a backoff that can total four seconds.
42+
// So set the timeout to be (3*10)+4 seconds to cover a worst case scenario.
43+
this.timeout(34000);
44+
this.slow(5000);
45+
return deployEndpoint(endpoint, dirname);
46+
});
47+
48+
runtests("run", endpoint, headers, tests);
5749
});
58-
59-
afterEach('log-failure', logOnFail)
60-
tests.forEach(
61-
({ label, documentId, query, variables, operationName, expected, authType }) => {
62-
it(label, async function () {
63-
this.timeout(4000); // Occasional requests take > 2s
64-
let request = {}
65-
if (query) {
66-
request.query = query;
67-
}
68-
if (documentId) {
69-
request.documentId = documentId;
70-
}
71-
if (operationName) {
72-
request.operationName = operationName;
73-
}
74-
if (variables) {
75-
request.variables = variables;
76-
}
77-
return await runGqlOk(
78-
endpoint,
79-
headers,
80-
request,
81-
expected,
82-
);
83-
});
84-
}
85-
);
8650
}
8751

8852
function getTestDescription(testRoot, fullDirName) {
@@ -96,4 +60,4 @@ function getTestDescription(testRoot, fullDirName) {
9660
exports.deployAndRun = deployAndRun;
9761
exports.getTestDescription = getTestDescription;
9862

99-
exports.stepzen = stepzen
63+
exports.stepzen = stepzen;

tests/package-lock.json

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"chain": "^0.2.1",
1010
"dotenv": "^16.0.3",
1111
"mocha": "^10.0.0",
12-
"gqltest": "stepzen-dev/gqltest#f951b93474db0a02798a1b9e00d54e252db4ca89"
12+
"gqltest": "stepzen-dev/gqltest#v0.1"
1313
},
1414
"keywords": [],
1515
"author": ""

0 commit comments

Comments
 (0)