1- import { spawn } from 'node:child_process' ;
1+ import { ChildProcessWithoutNullStreams , spawn } from 'node:child_process' ;
22import { readFile } from 'node:fs/promises' ;
33import path from 'node:path' ;
44import { GraphQLSchema , printSchema } from 'graphql' ;
@@ -39,8 +39,8 @@ describe('schema', async () => {
3939 } ) ;
4040
4141 describe ( 'UrlLoader' , ( ) => {
42- let local ;
43- let url ;
42+ let local : ChildProcessWithoutNullStreams ;
43+ let url : string ;
4444
4545 beforeAll (
4646 ( ) =>
@@ -64,8 +64,8 @@ describe('schema', async () => {
6464
6565 afterAll (
6666 ( ) =>
67- new Promise ( resolve => {
68- local . on ( 'close' , ( ) => resolve ( ) ) ;
67+ new Promise ( done => {
68+ local . on ( 'close' , ( ) => done ( ) ) ;
6969 local . kill ( ) ;
7070 } ) ,
7171 ) ;
@@ -75,7 +75,7 @@ describe('schema', async () => {
7575 } ) ;
7676
7777 describe ( 'should passe headers' , ( ) => {
78- let schemaUrl ;
78+ let schemaUrl : string ;
7979 let schemaOptions ;
8080
8181 beforeAll ( ( ) => {
@@ -95,27 +95,23 @@ describe('schema', async () => {
9595 } ,
9696 filePath : '' ,
9797 } ) ;
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"' ) ;
10199 } ) ;
102100
103101 // https://github.com/B2o5T/graphql-eslint/blob/master/docs/parser-options.md#schemaoptions
104102 it ( 'with `parserOptions.schemaOptions`' , ( ) => {
105103 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+ ) ;
109107 } ) ;
110108 } ) ;
111109 } ) ;
112110
113111 describe ( 'schema loading' , ( ) => {
114112 it ( 'should return Error' , ( ) => {
115113 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 (
119115 'Unable to find any GraphQL type definitions for the following pointers' ,
120116 ) ;
121117 } ) ;
0 commit comments