#How to allow self signed certificates in integration tests that use HttpModule

2 messages · Page 1 of 1 (latest)

dusty quail
#

I've been trying to find how to disable the certificate checks in testing environments. I tried adding NODE_TLS_REJECT_UNAUTHORIZED=0 to .env file but that didn't help. I'm guessing I should set the rejectUnauthorized to false for axios, but I don't know where I could do that when importing HttpModule in the test setup.

heavy depot
# dusty quail I've been trying to find how to disable the certificate checks in testing enviro...

HttpModule is just a wrapper around the axios package, and its module registration options are pretty much the same
so I'm assuming you can overwrite the HTTPS agent like this while registering the module

import { Agent } from 'https';


const module: TestingModule = await Test.createTestingModule({
  imports: [
    HttpModule.register({
      httpsAgent: new Agent({
        rejectUnauthorized: false,
      }),
    }),
  ],
  providers: [TestService],
}).compile();