1
- import { expect , test } from '@jest/globals '
1
+ import { expect , test } from 'vitest '
2
2
3
3
import { assert2xx } from '../fetchStream'
4
4
@@ -25,10 +25,12 @@ test('server responds with 4xx and error response', () => {
25
25
message : 'More details' ,
26
26
} ) ,
27
27
}
28
- expect ( assert2xx ( mockResponse as unknown as Response ) ) . rejects . toThrowError ( {
29
- statusCode : 400 ,
30
- message : 'Error message: More details' ,
31
- } )
28
+ expect ( assert2xx ( mockResponse as unknown as Response ) ) . rejects . toThrowError (
29
+ expect . objectContaining ( {
30
+ statusCode : 400 ,
31
+ message : 'Error message: More details' ,
32
+ } ) ,
33
+ )
32
34
} )
33
35
34
36
test ( 'server responds with 5xx and no json response' , ( ) => {
@@ -37,10 +39,12 @@ test('server responds with 5xx and no json response', () => {
37
39
statusText : 'Internal Server Error' ,
38
40
json : ( ) => Promise . reject ( new Error ( 'Failed to parse JSON' ) ) ,
39
41
}
40
- expect ( assert2xx ( mockResponse as unknown as Response ) ) . rejects . toThrowError ( {
41
- statusCode : 500 ,
42
- message : 'HTTP Error 500: Internal Server Error' ,
43
- } )
42
+ expect ( assert2xx ( mockResponse as unknown as Response ) ) . rejects . toThrowError (
43
+ expect . objectContaining ( {
44
+ statusCode : 500 ,
45
+ message : 'HTTP Error 500: Internal Server Error' ,
46
+ } ) ,
47
+ )
44
48
} )
45
49
46
50
test ( 'server responds with 5xx and json response' , ( ) => {
@@ -56,8 +60,10 @@ test('server responds with 5xx and json response', () => {
56
60
status : 500 ,
57
61
} ) ,
58
62
}
59
- expect ( assert2xx ( mockResponse as unknown as Response ) ) . rejects . toThrowError ( {
60
- statusCode : 500 ,
61
- message : 'validationError: Document is not of valid type' ,
62
- } )
63
+ expect ( assert2xx ( mockResponse as unknown as Response ) ) . rejects . toThrowError (
64
+ expect . objectContaining ( {
65
+ statusCode : 500 ,
66
+ message : 'validationError: Document is not of valid type' ,
67
+ } ) ,
68
+ )
63
69
} )
0 commit comments