@yeepay/yop-nodejs-sdk
Version:
YOP NodeJS SDK with TypeScript support
30 lines (25 loc) • 2.36 kB
Markdown
# Task: Mock Test Dependencies to Fix Crypto Error
**Status:** Pending
**Coordinator:** TASK-CMD-20250419-151900
**Assigned To:** typescript-specialist
**Goal:** Modify `src/test/request.ts` to mock the necessary functions (e.g., `axios.request` or `RsaV3Util.getAuthHeaders`) so that `npm test` can run without the `error:1E08010C:DECODER routines::unsupported` crypto error and without making actual network calls. The primary goal is to allow the test suite *execution* to proceed past the crypto error.
**Acceptance Criteria:**
* Running `npm test` no longer throws the `DECODER routines::unsupported` error originating from `RsaV3Util.ts`.
* The test suite (`src/test/request.ts`) executes within Jest. (Individual test logic/assertions within the suite might still fail or need further implementation, which is outside the scope of *this* specific task).
* No actual network requests are made during the test run.
**Context Files:**
* `src/test/request.ts` (Current version with placeholder key)
* `src/Util/RsaV3Util.ts` (Contains the failing `getAuthHeaders` function)
* Latest `npm test` output showing the `DECODER` error.
**Checklist:**
- [ ] Analyze `src/test/request.ts` and `src/Util/RsaV3Util.ts`.
- [ ] Determine the best mocking strategy. Mocking `axios.request` seems like a good approach to bypass both crypto and network issues for this test file's structure. Alternatively, mocking `RsaV3Util.getAuthHeaders` could also work.
- [ ] Implement the chosen mocking strategy in `src/test/request.ts` using Jest's mocking functions (e.g., `jest.mock`, `jest.spyOn`).
- [ ] Ensure the mock prevents the `DECODER` error and network calls.
- [ ] Verify that `npm test` executes the test suite without the crypto error.
- [📣] Report completion with the changes made.
---
**Status:** ✅ Complete
**Outcome:** Success - Mocked dependencies and resolved crypto error
**Summary:** Added Jest mocks for `axios` and `RsaV3Util` at the beginning of `src/test/request.ts`. This successfully bypassed the `DECODER routines::unsupported` error originating from `RsaV3Util.getAuthHeaders` and prevented actual network calls via `axios.request`. Added a placeholder test case (`test(...)`) to satisfy Jest's requirement for at least one test, allowing the test suite to pass execution.
**References:** [`src/test/request.ts` (modified)]