-
Notifications
You must be signed in to change notification settings - Fork 2k
/
smoke-test.mts
39 lines (34 loc) 路 912 Bytes
/
smoke-test.mts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import fetch from 'make-fetch-happen';
import assert from 'assert';
async function smokeTest() {
const s = new ApolloServer({
typeDefs: 'type Query {hello:String}',
resolvers: {
Query: {
hello() {
return 'world';
},
},
},
});
const { url } = await startStandaloneServer(s, { listen: { port: 0 } });
const response = await fetch(url, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ query: '{hello}' }),
});
const body = await response.json();
assert.strictEqual(body.data.hello, 'world');
await s.stop();
}
smokeTest()
.then(() => {
console.log('TS-ESM smoke test passed!');
process.exit(0);
})
.catch((e) => {
console.error(e);
process.exit(1);
});