• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ProjectOpenSea / opensea-js / 18541551701
88%
master: 30%

Build:
Build:
LAST BUILD BRANCH: renovate/prettier-3.x-lockfile
DEFAULT BRANCH: master
Ran 15 Oct 2025 08:20PM UTC
Jobs 1
Files 67
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

15 Oct 2025 08:19PM UTC coverage: 87.318% (+0.5%) from 86.787%
18541551701

push

github

web-flow
feat: add Fetcher interface, test fixture, and improve API architecture (#1787)

This commit introduces a dependency injection pattern for API classes using the Fetcher interface, making the codebase more maintainable and testable.

## Changes

### Core Architecture
- **Fetcher Interface**: Created `src/api/fetcher.ts` defining a clean abstraction for HTTP operations (get/post methods)
- **API Refactoring**: Updated all API classes (OrdersAPI, OffersAPI, ListingsAPI, CollectionsAPI, NFTsAPI, AccountsAPI, EventsAPI) to accept a Fetcher dependency instead of individual get/post functions
- **OpenSeaAPI Update**: Modified to create and pass a fetcher context to all API clients

### Testing Infrastructure
- **Mock Fetcher Fixture**: Created `test/fixtures/fetcher.ts` providing a reusable `createMockFetcher()` function for consistent test mocking
- **Test Refactoring**: Updated all API test files to use the new fixture, ensuring consistent mocking patterns across the test suite
- **Fetcher Tests**: Added comprehensive test suite in `test/api/fetcher.spec.ts` with 14 test cases covering interface implementation, generic types, error handling, and dependency injection patterns

### Bug Fixes
- Fixed `serializeOrdersQueryOptions` in `src/orders/utils.ts` to handle `next` parameter with fallback: `cursor: options.cursor ?? options.next`

### Documentation
- Added API reference documentation in `developerDocs/api-reference.md`

## Benefits
- **Improved Testability**: Mock fetcher fixture enables consistent and easier test setup across all API tests
- **Better Separation of Concerns**: Fetcher interface decouples HTTP client implementation from API logic
- **Enhanced Maintainability**: Dependency injection pattern makes code more flexible and easier to maintain
- **Type Safety**: Full TypeScript support with generics for type-safe HTTP responses

## Testing
- All 333 existing tests pass
- All linting checks pass (TypeScript, ESLint, Prettier)

🤖 Generated with [... (continued)

432 of 625 branches covered (69.12%)

Branch coverage included in aggregate %.

425 of 451 new or added lines in 17 files covered. (94.24%)

1 existing line in 1 file now uncovered.

3885 of 4319 relevant lines covered (89.95%)

4.39 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
1
70.0
0.0% src/api/accounts.ts
1
96.88
0.36% test/api/listings.spec.ts
1
95.93
0.12% test/api/offers.spec.ts
2
97.18
0.12% test/api/collections.spec.ts
2
96.84
-0.07% test/api/nfts.spec.ts
3
66.22
-0.45% src/api/orders.ts
4
54.14
-2.24% src/api/api.ts
12
90.77
test/api/fetcher.spec.ts

Uncovered Existing Lines

Lines Coverage ∆ File
1
70.0
0.0% src/api/accounts.ts
Jobs
ID Job ID Ran Files Coverage
1 18541551701.1 15 Oct 2025 08:20PM UTC 67
87.32
GitHub Action Run
Source Files on build 18541551701
  • Tree
  • List 67
  • Changed 17
  • Source Changed 0
  • Coverage Changed 17
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • 257b8e95 on github
  • Prev Build on main (#18540449053)
  • Next Build on main (#18541823153)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc