@@ -29,10 +29,16 @@ describe('plugin Testing', () => {
29
29
expect ( this . childPropertyService ) . toBeInstanceOf ( ChildService )
30
30
expect ( this . childPropertyService . foo ) . toBe ( 'bar' )
31
31
}
32
+
33
+ willThrowError ( ) {
34
+ throw new Error ( 'Test error!' )
35
+ }
32
36
}
33
37
34
38
class TestingApp extends AbstractBootstrap {
35
39
async run ( ) : Promise < void > {
40
+ let hasWillThrowError = false
41
+
36
42
super . use ( {
37
43
name : 'test' ,
38
44
@@ -42,6 +48,19 @@ describe('plugin Testing', () => {
42
48
const testServiceInstance = await testClassWrapper . resolve ( )
43
49
expect ( testServiceInstance ) . toBeInstanceOf ( TestService )
44
50
51
+ // Custom error handler
52
+ try {
53
+ testServiceInstance . willThrowError ( )
54
+ }
55
+ catch ( error ) {
56
+ await this . handle ( {
57
+ classWrapper : testClassWrapper ,
58
+ error,
59
+ propertyKey : 'willThrowError' ,
60
+ methodArguments : [ ] ,
61
+ } )
62
+ }
63
+
45
64
const testValueWrapper = bootstrap . createValue ( 'test-value' , 'test-value-token' )
46
65
expect ( isValueWrapper ( testValueWrapper ) ) . toBe ( true )
47
66
expect ( testValueWrapper . getValue ( ) ) . toBe ( 'test-value' )
@@ -153,9 +172,14 @@ describe('plugin Testing', () => {
153
172
expect ( ctx . getPropertyKey ( ) ) . toBe ( 'onReady' )
154
173
expect ( ctx . getMethodArguments ( ) ) . toEqual ( [ 'test-arg-in-invoke-hook' ] )
155
174
}
175
+
176
+ if ( ctx . getPropertyKey ( ) === 'willThrowError' ) {
177
+ hasWillThrowError = true
178
+ }
156
179
} ,
157
180
} )
158
181
await super . initialize ( )
182
+ expect ( hasWillThrowError ) . toBe ( true )
159
183
}
160
184
}
161
185
0 commit comments