@@ -12,11 +12,13 @@ describe("Certificate errors", () => {
1212 // Before each test we make a request to sanity check that we really get the
1313 // error we are expecting, then we run it through CertificateError.
1414
15- // Some tests behave differently in Electron (BoringSSL) vs Node.js (OpenSSL).
16- // Run `yarn test:electron` to test Electron-specific behavior.
17- const isElectron =
18- ( process . versions . electron || process . env . ELECTRON_RUN_AS_NODE ) &&
19- ! process . env . VSCODE_PID ; // Running from the test explorer in VS Code
15+ // These tests run in Electron (BoringSSL) for accurate certificate validation testing.
16+
17+ it ( "should run in Electron environment" , ( ) => {
18+ const isElectron =
19+ process . versions . electron || process . env . ELECTRON_RUN_AS_NODE ;
20+ expect ( isElectron ) . toBeTruthy ( ) ;
21+ } ) ;
2022
2123 beforeAll ( ( ) => {
2224 vi . mock ( "vscode" , ( ) => {
@@ -121,26 +123,16 @@ describe("Certificate errors", () => {
121123 servername : "localhost" ,
122124 } ) ,
123125 } ) ;
124- if ( isElectron ) {
125- await expect ( request ) . rejects . toHaveProperty (
126- "code" ,
127- X509_ERR_CODE . UNABLE_TO_VERIFY_LEAF_SIGNATURE ,
128- ) ;
129- try {
130- await request ;
131- } catch ( error ) {
132- const wrapped = await CertificateError . maybeWrap (
133- error ,
134- address ,
135- logger ,
136- ) ;
137- expect ( wrapped instanceof CertificateError ) . toBeTruthy ( ) ;
138- expect ( ( wrapped as CertificateError ) . x509Err ) . toBe (
139- X509_ERR . NON_SIGNING ,
140- ) ;
141- }
142- } else {
143- await expect ( request ) . resolves . toHaveProperty ( "data" , "foobar" ) ;
126+ await expect ( request ) . rejects . toHaveProperty (
127+ "code" ,
128+ X509_ERR_CODE . UNABLE_TO_VERIFY_LEAF_SIGNATURE ,
129+ ) ;
130+ try {
131+ await request ;
132+ } catch ( error ) {
133+ const wrapped = await CertificateError . maybeWrap ( error , address , logger ) ;
134+ expect ( wrapped instanceof CertificateError ) . toBeTruthy ( ) ;
135+ expect ( ( wrapped as CertificateError ) . x509Err ) . toBe ( X509_ERR . NON_SIGNING ) ;
144136 }
145137 } ) ;
146138
0 commit comments