normalizeBigNumbers Reference
This is a reference to the normalizeBigNumbers function provided by the @medusajs/test-utils package.
Summary#
normalizeBigNumbers recursively converts BigNumber instances to plain JavaScript numbers within any object, array, or primitive value. Dates are left intact.
When you retrieve or create orders and carts in tests, numeric fields such as totals are returned as BigNumber instances rather than plain numbers. Use normalizeBigNumbers when writing Jest assertions against those values so you can compare them to plain-number expectations.
Example#
1import { medusaIntegrationTestRunner, normalizeBigNumbers } from "@medusajs/test-utils"2 3medusaIntegrationTestRunner({4 testSuite: ({ api }) => {5 it("returns the correct order totals", async () => {6 const { data: { order } } = await api.get("/admin/orders/order_123")7 8 expect(normalizeBigNumbers(order)).toMatchObject({9 total: 50,10 subtotal: 45,11 tax_total: 5,12 })13 })14 },15})
Parameters#
Name | Type | Description |
|---|---|---|
|
| The value to normalize. Can be a |
Returns#
Returns the normalized value with all BigNumber instances replaced by plain number values. The original structure (objects, arrays) is preserved. Date instances are returned as-is.