Skip to content

Conversation

@luisaveiro
Copy link
Member

Purpose

This branch provides a timeout method that specifies the maximum number of milliseconds to wait for a response.

timeout method signature

The timeout method accepts the maximum number of milliseconds the request should wait for a response..

timeout(milliseconds: number)
Example of timeout method
const response = new HttpClient()
  .timeout(1000)
  .get('https://api.example.local/test/');
Test Refactoring

I had to refactor the HTTP Client tests to allow the ability to test the timeout functionality. I replaced the code to mock fetch() with the Mock Service Worker (MSW) package. This package can intercept outgoing requests, observe them, and respond to them using mocked responses. This provides a more robust testing solution.


Related Issue

Please link to the issue/discussion here: #42


Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to change).
  • Refactoring.
  • Other (documentation).

Are breaking changes introduced?

No breaking changes


How Has This Been Tested?

  • Changes are covered by existing tests.
  • Changes are covered by new tests.
  • Changes are not covered by tests.

Development Checklist

  • My code follows our coding standards.
  • All new and existing tests passed.
  • I have read the CONTRIBUTING document.
  • I have updated the CHANGELOG accordingly.
  • I have updated the README, if necessary.

@luisaveiro luisaveiro added enhancement New feature or request refactoring Restructuring code while not changing its original functionality labels Feb 12, 2024
@luisaveiro luisaveiro self-assigned this Feb 12, 2024
@sonarqubecloud
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@luisaveiro luisaveiro merged commit 167a70a into main Feb 12, 2024
@luisaveiro luisaveiro deleted the feature/timeout branch February 12, 2024 23:41
@ageddesi
Copy link

That all looks awesome :) Someone has been busy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request refactoring Restructuring code while not changing its original functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants