Skip to content

Commit

Permalink
✅ Use dynamic imports instead of require.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaditmshah committed Sep 29, 2022
1 parent 3237e0a commit 2c13df3
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions test/utils/buildFetchOptions.spec.js
Expand Up @@ -103,11 +103,12 @@ describe('buildFetchOptions', () => {

describe('when using an anonymous proxy', () => {
describe('when is http proxy', () => {
it('should return an object containing a proxy agent', () => {
it('should return an object containing a proxy agent', async () => {
process.env.http_proxy = 'http://localhost-env:8080'

const buildFetchOptionsFromEnv = require('../../src/utils/buildFetchOptions')
.default
const { default: buildFetchOptionsFromEnv } = await import(
'../../src/utils/buildFetchOptions'
)

expect(buildFetchOptionsFromEnv()).toMatchObject({
agent: {
Expand All @@ -126,11 +127,12 @@ describe('buildFetchOptions', () => {
})

describe('when is https proxy', () => {
it('should return an object containing a proxy agent', () => {
it('should return an object containing a proxy agent', async () => {
process.env.https_proxy = 'https://localhost-env:8080'

const buildFetchOptionsFromEnv = require('../../src/utils/buildFetchOptions')
.default
const { default: buildFetchOptionsFromEnv } = await import(
'../../src/utils/buildFetchOptions'
)

expect(buildFetchOptionsFromEnv()).toMatchObject({
agent: {
Expand All @@ -151,11 +153,12 @@ describe('buildFetchOptions', () => {

describe('when using an authenticated proxy', () => {
describe('when is http proxy', () => {
it('should return an object containing a proxy agent', () => {
it('should return an object containing a proxy agent', async () => {
process.env.http_proxy = 'http://user:pass@localhost-env:8080'

const buildFetchOptionsFromEnv = require('../../src/utils/buildFetchOptions')
.default
const { default: buildFetchOptionsFromEnv } = await import(
'../../src/utils/buildFetchOptions'
)

expect(buildFetchOptionsFromEnv()).toMatchObject({
agent: {
Expand All @@ -174,11 +177,12 @@ describe('buildFetchOptions', () => {
})

describe('when is https proxy', () => {
it('should return an object containing a proxy agent', () => {
it('should return an object containing a proxy agent', async () => {
process.env.https_proxy = 'https://user:pass@localhost-env:8080'

const buildFetchOptionsFromEnv = require('../../src/utils/buildFetchOptions')
.default
const { default: buildFetchOptionsFromEnv } = await import(
'../../src/utils/buildFetchOptions'
)

expect(buildFetchOptionsFromEnv()).toMatchObject({
agent: {
Expand Down

0 comments on commit 2c13df3

Please sign in to comment.