Skip to content

Use vi.spyOn to mock so we don't leak states

Lin Jen-Shin requested to merge fix-test-cache-state-leak into main

This fixes this error when there are more tests using the same cache:

 FAIL  test/index.spec.ts > when rules are configured > with `session_prefix` rule > when force-cell cookie is matched > when value matched the format > sets correct headers
TypeError: Body has already been used. It can only be used once. Use tee() first if you need to read it twice.
 ❯ Module.classifyFetch src/topology_service/classify.ts:25:19
     23|   }
     24|
     25|   return response.json() as Promise<ClassifyResponse>;
       |                   ^
     26| }
     27|
 ❯ ClassifyRule.fetch src/rules/classify.ts:21:22
 ❯ workerFetchRequest test/index.spec.ts:62:20
 ❯ test/index.spec.ts:389:28

This was discovered at #20 (comment 2096621940)

Related to #59 (closed)

Edited by Lin Jen-Shin

Merge request reports

Loading