forked from apollographql/apollo-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmoke-test.mts
53 lines (46 loc) · 1.42 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import fetch from 'make-fetch-happen';
import assert from 'assert';
async function validateAllImports() {
await import('@apollo/server');
await import('@apollo/server/plugin/cacheControl');
await import('@apollo/server/plugin/disabled');
await import('@apollo/server/plugin/drainHttpServer');
await import('@apollo/server/plugin/inlineTrace');
await import('@apollo/server/plugin/landingPage/default');
await import('@apollo/server/plugin/schemaReporting');
await import('@apollo/server/plugin/usageReporting');
await import('@apollo/server/standalone');
}
async function smokeTest() {
await validateAllImports();
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);
});