1
- import { spawn } from 'node:child_process' ;
1
+ import { ChildProcessWithoutNullStreams , spawn } from 'node:child_process' ;
2
2
import { readFile } from 'node:fs/promises' ;
3
3
import path from 'node:path' ;
4
4
import { GraphQLSchema , printSchema } from 'graphql' ;
@@ -39,8 +39,8 @@ describe('schema', async () => {
39
39
} ) ;
40
40
41
41
describe ( 'UrlLoader' , ( ) => {
42
- let local ;
43
- let url ;
42
+ let local : ChildProcessWithoutNullStreams ;
43
+ let url : string ;
44
44
45
45
beforeAll (
46
46
( ) =>
@@ -64,8 +64,8 @@ describe('schema', async () => {
64
64
65
65
afterAll (
66
66
( ) =>
67
- new Promise ( resolve => {
68
- local . on ( 'close' , ( ) => resolve ( ) ) ;
67
+ new Promise ( done => {
68
+ local . on ( 'close' , ( ) => done ( ) ) ;
69
69
local . kill ( ) ;
70
70
} ) ,
71
71
) ;
@@ -75,7 +75,7 @@ describe('schema', async () => {
75
75
} ) ;
76
76
77
77
describe ( 'should passe headers' , ( ) => {
78
- let schemaUrl ;
78
+ let schemaUrl : string ;
79
79
let schemaOptions ;
80
80
81
81
beforeAll ( ( ) => {
@@ -95,27 +95,23 @@ describe('schema', async () => {
95
95
} ,
96
96
filePath : '' ,
97
97
} ) ;
98
- const error = getSchema ( gqlConfig . getDefault ( ) ) as Error ;
99
- expect ( error ) . toBeInstanceOf ( Error ) ;
100
- expect ( error . message ) . toMatch ( 'authorization: "Bearer Foo"' ) ;
98
+ expect ( ( ) => getSchema ( gqlConfig . getDefault ( ) ) ) . toThrow ( 'authorization: "Bearer Foo"' ) ;
101
99
} ) ;
102
100
103
101
// https://github.com/B2o5T/graphql-eslint/blob/master/docs/parser-options.md#schemaoptions
104
102
it ( 'with `parserOptions.schemaOptions`' , ( ) => {
105
103
const gqlConfig = loadGraphQLConfig ( { schema : schemaUrl , filePath : '' } ) ;
106
- const error = getSchema ( gqlConfig . getDefault ( ) , schemaOptions ) as Error ;
107
- expect ( error ) . toBeInstanceOf ( Error ) ;
108
- expect ( error . message ) . toMatch ( 'authorization: "Bearer Foo"' ) ;
104
+ expect ( ( ) => getSchema ( gqlConfig . getDefault ( ) , schemaOptions ) ) . toThrow (
105
+ 'authorization: "Bearer Foo"' ,
106
+ ) ;
109
107
} ) ;
110
108
} ) ;
111
109
} ) ;
112
110
113
111
describe ( 'schema loading' , ( ) => {
114
112
it ( 'should return Error' , ( ) => {
115
113
const gqlConfig = loadGraphQLConfig ( { schema : 'not-exist.gql' , filePath : '' } ) ;
116
- const error = getSchema ( gqlConfig . getDefault ( ) ) as Error ;
117
- expect ( error ) . toBeInstanceOf ( Error ) ;
118
- expect ( error . message ) . toMatch (
114
+ expect ( ( ) => getSchema ( gqlConfig . getDefault ( ) ) ) . toThrow (
119
115
'Unable to find any GraphQL type definitions for the following pointers' ,
120
116
) ;
121
117
} ) ;
0 commit comments