File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
extensions/ql-vscode/test/unit-tests/common Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,40 @@ describe("errorMessage", () => {
1919 ) . toEqual ( "Failed to create database foo" ) ;
2020 } ) ;
2121
22+ it ( "fullMessageWithStack includes the stack" , ( ) => {
23+ expect (
24+ redactableError `Failed to create database ${ "foo" } ` . fullMessageWithStack ,
25+ ) . toMatch (
26+ / ^ F a i l e d t o c r e a t e d a t a b a s e f o o \n E r r o r : F a i l e d t o c r e a t e d a t a b a s e f o o \n + a t r e d a c t a b l e E r r o r \( / ,
27+ ) ;
28+ } ) ;
29+
30+ it ( "fullMessageWithStack includes the cause stack for given error" , ( ) => {
31+ function myRealFunction ( ) {
32+ throw new Error ( "Internal error" ) ;
33+ }
34+
35+ let error : Error ;
36+ try {
37+ myRealFunction ( ) ;
38+
39+ fail ( "Expected an error to be thrown" ) ;
40+ } catch ( e : unknown ) {
41+ if ( ! ( e instanceof Error ) ) {
42+ throw new Error ( "Expected an Error to be thrown" ) ;
43+ }
44+
45+ error = e ;
46+ }
47+
48+ expect (
49+ redactableError ( error ) `Failed to create database ${ "foo" } `
50+ . fullMessageWithStack ,
51+ ) . toMatch (
52+ / ^ F a i l e d t o c r e a t e d a t a b a s e f o o \n E r r o r : I n t e r n a l e r r o r \n + a t m y R e a l F u n c t i o n \( / ,
53+ ) ;
54+ } ) ;
55+
2256 it ( "redactedMessage redacts the given message" , ( ) => {
2357 expect (
2458 redactableError `Failed to create database ${ "foo" } ` . redactedMessage ,
You can’t perform that action at this time.
0 commit comments