diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 0e1423b25c..0e0bad86ca 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -143,7 +143,7 @@ jobs: working-directory: integration-tests/api - name: Run integration tests - run: yarn test --runInBand + run: yarn test working-directory: integration-tests/api env: DB_PASSWORD: postgres diff --git a/integration-tests/api/__tests__/admin/auth.js b/integration-tests/api/__tests__/admin/auth.js index 39eb1807e1..3473e55a06 100644 --- a/integration-tests/api/__tests__/admin/auth.js +++ b/integration-tests/api/__tests__/admin/auth.js @@ -18,11 +18,7 @@ describe("/admin/auth", () => { dbConnection = await initDb({ cwd }) medusaProcess = await setupServer({ cwd }) - try { - await adminSeeder(dbConnection) - } catch (e) { - throw e - } + await adminSeeder(dbConnection) }) afterAll(async () => { diff --git a/integration-tests/api/__tests__/admin/colllections.js b/integration-tests/api/__tests__/admin/colllections.js index 4f47d1efa2..a3abda4f35 100644 --- a/integration-tests/api/__tests__/admin/colllections.js +++ b/integration-tests/api/__tests__/admin/colllections.js @@ -25,13 +25,8 @@ describe("/admin/collections", () => { describe("/admin/collections/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await productSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await productSeeder(dbConnection) }) afterEach(async () => { @@ -128,13 +123,8 @@ describe("/admin/collections", () => { describe("/admin/collections", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await productSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await productSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/customer-groups.js b/integration-tests/api/__tests__/admin/customer-groups.js index d9b27b97ca..3609a8312e 100644 --- a/integration-tests/api/__tests__/admin/customer-groups.js +++ b/integration-tests/api/__tests__/admin/customer-groups.js @@ -27,13 +27,8 @@ describe("/admin/customer-groups", () => { describe("POST /admin/customer-groups", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) }) afterEach(async () => { @@ -88,13 +83,8 @@ describe("/admin/customer-groups", () => { describe("DELETE /admin/customer-groups", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) }) afterEach(async () => { @@ -195,13 +185,8 @@ describe("/admin/customer-groups", () => { describe("GET /admin/customer-groups/{id}/customers", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) }) afterEach(async () => { @@ -242,13 +227,8 @@ describe("/admin/customer-groups", () => { describe("POST /admin/customer-groups/{id}/customers/batch", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) }) afterEach(async () => { @@ -418,13 +398,8 @@ describe("/admin/customer-groups", () => { describe("POST /admin/customer-groups/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) }) afterEach(async () => { @@ -500,13 +475,8 @@ describe("/admin/customer-groups", () => { describe("GET /admin/customer-groups", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) }) afterEach(async () => { @@ -559,13 +529,8 @@ describe("/admin/customer-groups", () => { describe("GET /admin/customer-groups/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) }) afterEach(async () => { @@ -641,13 +606,8 @@ describe("/admin/customer-groups", () => { describe("DELETE /admin/customer-groups/{id}/batch", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/customer.js b/integration-tests/api/__tests__/admin/customer.js index 46540422a2..b515203b78 100644 --- a/integration-tests/api/__tests__/admin/customer.js +++ b/integration-tests/api/__tests__/admin/customer.js @@ -28,13 +28,8 @@ describe("/admin/customers", () => { describe("GET /admin/customers", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) }) afterEach(async () => { @@ -164,12 +159,7 @@ describe("/admin/customers", () => { describe("POST /admin/customers", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) }) afterEach(async () => { @@ -213,13 +203,8 @@ describe("/admin/customers", () => { describe("POST /admin/customers/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) }) afterEach(async () => { @@ -368,13 +353,8 @@ describe("/admin/customers", () => { describe("GET /admin/customers/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/discount.js b/integration-tests/api/__tests__/admin/discount.js index 7b3982bc1c..3b8d3f10f5 100644 --- a/integration-tests/api/__tests__/admin/discount.js +++ b/integration-tests/api/__tests__/admin/discount.js @@ -427,13 +427,8 @@ describe("/admin/discounts", () => { describe("POST /admin/discounts", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await discountSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await discountSeeder(dbConnection) }) afterEach(async () => { @@ -2150,11 +2145,7 @@ describe("/admin/discounts", () => { describe("GET /admin/discounts/:id/conditions/:condition_id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - } + await adminSeeder(dbConnection) const prod = await simpleProductFactory(dbConnection, { type: "pants", diff --git a/integration-tests/api/__tests__/admin/draft-order.js b/integration-tests/api/__tests__/admin/draft-order.js index 272635d149..be34f01200 100644 --- a/integration-tests/api/__tests__/admin/draft-order.js +++ b/integration-tests/api/__tests__/admin/draft-order.js @@ -28,13 +28,8 @@ describe("/admin/draft-orders", () => { describe("POST /admin/draft-orders", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await draftOrderSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await draftOrderSeeder(dbConnection) }) afterEach(async () => { @@ -359,7 +354,7 @@ describe("/admin/draft-orders", () => { const payload = { email: "oli@test.dk", shipping_address: "oli-shipping", - discounts: [{ code: "TEST" }, { code: "free-shipping"}], + discounts: [{ code: "TEST" }, { code: "free-shipping" }], items: [ { variant_id: "test-variant", @@ -426,7 +421,7 @@ describe("/admin/draft-orders", () => { }), expect.objectContaining({ code: "free-shipping", - }) + }), ]) ) }) @@ -524,12 +519,8 @@ describe("/admin/draft-orders", () => { }) describe("GET /admin/draft-orders", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await draftOrderSeeder(dbConnection) - } catch (err) { - throw err - } + await adminSeeder(dbConnection) + await draftOrderSeeder(dbConnection) }) afterEach(async () => { @@ -605,13 +596,8 @@ describe("/admin/draft-orders", () => { describe("DELETE /admin/draft-orders/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await draftOrderSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await draftOrderSeeder(dbConnection) }) afterEach(async () => { @@ -644,12 +630,8 @@ describe("/admin/draft-orders", () => { describe("POST /admin/draft-orders/:id/line-items/:line_id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await draftOrderSeeder(dbConnection, { status: "open" }) - } catch (err) { - throw err - } + await adminSeeder(dbConnection) + await draftOrderSeeder(dbConnection, { status: "open" }) }) afterEach(async () => { @@ -733,12 +715,8 @@ describe("/admin/draft-orders", () => { describe("POST /admin/draft-orders/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await draftOrderSeeder(dbConnection, { status: "open" }) - } catch (err) { - throw err - } + await adminSeeder(dbConnection) + await draftOrderSeeder(dbConnection, { status: "open" }) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/gift-cards.js b/integration-tests/api/__tests__/admin/gift-cards.js index 505354159d..56a5539190 100644 --- a/integration-tests/api/__tests__/admin/gift-cards.js +++ b/integration-tests/api/__tests__/admin/gift-cards.js @@ -28,32 +28,28 @@ describe("/admin/gift-cards", () => { describe("GET /admin/gift-cards", () => { beforeEach(async () => { const manager = dbConnection.manager - try { - await adminSeeder(dbConnection) - await manager.insert(Region, { - id: "test-region", - name: "Test Region", - currency_code: "usd", - tax_rate: 0, - }) - await manager.insert(GiftCard, { - id: "gift_test", - code: "GC_TEST", - value: 20000, - balance: 20000, - region_id: "test-region", - }) - await manager.insert(GiftCard, { - id: "another_gift_test", - code: "CARD_TEST", - value: 200000, - balance: 200000, - region_id: "test-region", - }) - } catch (err) { - console.log(err) - throw err - } + + await adminSeeder(dbConnection) + await manager.insert(Region, { + id: "test-region", + name: "Test Region", + currency_code: "usd", + tax_rate: 0, + }) + await manager.insert(GiftCard, { + id: "gift_test", + code: "GC_TEST", + value: 20000, + balance: 20000, + region_id: "test-region", + }) + await manager.insert(GiftCard, { + id: "another_gift_test", + code: "CARD_TEST", + value: 200000, + balance: 200000, + region_id: "test-region", + }) }) afterEach(async () => { @@ -136,25 +132,21 @@ describe("/admin/gift-cards", () => { describe("POST /admin/gift-cards", () => { beforeEach(async () => { const manager = dbConnection.manager - try { - await adminSeeder(dbConnection) - await manager.insert(Region, { - id: "region", - name: "Test Region", - currency_code: "usd", - tax_rate: 0, - }) - await manager.insert(GiftCard, { - id: "gift_test", - code: "GC_TEST", - value: 20000, - balance: 20000, - region_id: "region", - }) - } catch (err) { - console.log(err) - throw err - } + + await adminSeeder(dbConnection) + await manager.insert(Region, { + id: "region", + name: "Test Region", + currency_code: "usd", + tax_rate: 0, + }) + await manager.insert(GiftCard, { + id: "gift_test", + code: "GC_TEST", + value: 20000, + balance: 20000, + region_id: "region", + }) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/note.js b/integration-tests/api/__tests__/admin/note.js index 6e3bd05df0..4923f5cbd7 100644 --- a/integration-tests/api/__tests__/admin/note.js +++ b/integration-tests/api/__tests__/admin/note.js @@ -36,13 +36,10 @@ describe("/admin/notes", () => { describe("GET /admin/notes/:id", () => { beforeEach(async () => { const manager = dbConnection.manager - try { - await adminSeeder(dbConnection) - await manager.insert(Note, note) - } catch (err) { - console.log(err) - } + await adminSeeder(dbConnection) + + await manager.insert(Note, note) }) afterEach(async () => { @@ -73,11 +70,7 @@ describe("/admin/notes", () => { describe("POST /admin/notes", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - } + await adminSeeder(dbConnection) }) afterEach(async () => { @@ -121,19 +114,16 @@ describe("/admin/notes", () => { describe("GET /admin/notes", () => { beforeEach(async () => { const manager = dbConnection.manager - try { - await adminSeeder(dbConnection) - await manager.insert(Note, { ...note, id: "note1" }) - await manager.insert(Note, { ...note, id: "note2" }) - await manager.insert(Note, { - ...note, - id: "note3", - resource_id: "resource2", - }) - } catch (err) { - console.log(err) - } + await adminSeeder(dbConnection) + + await manager.insert(Note, { ...note, id: "note1" }) + await manager.insert(Note, { ...note, id: "note2" }) + await manager.insert(Note, { + ...note, + id: "note3", + resource_id: "resource2", + }) }) afterEach(async () => { @@ -178,13 +168,10 @@ describe("/admin/notes", () => { describe("POST /admin/notes/:id", () => { beforeEach(async () => { const manager = dbConnection.manager - try { - await adminSeeder(dbConnection) - await manager.insert(Note, note) - } catch (err) { - console.log(err) - } + await adminSeeder(dbConnection) + + await manager.insert(Note, note) }) afterEach(async () => { @@ -226,13 +213,10 @@ describe("/admin/notes", () => { describe("DELETE /admin/notes/:id", () => { beforeEach(async () => { const manager = dbConnection.manager - try { - await adminSeeder(dbConnection) - await manager.insert(Note, note) - } catch (err) { - console.log(err) - } + await adminSeeder(dbConnection) + + await manager.insert(Note, note) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/order.js b/integration-tests/api/__tests__/admin/order.js index a90b607546..32b7af183e 100644 --- a/integration-tests/api/__tests__/admin/order.js +++ b/integration-tests/api/__tests__/admin/order.js @@ -44,13 +44,8 @@ describe("/admin/orders", () => { describe("GET /admin/orders", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await orderSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await orderSeeder(dbConnection) }) afterEach(async () => { @@ -129,14 +124,9 @@ describe("/admin/orders", () => { describe("GET /admin/orders", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await orderSeeder(dbConnection) - await swapSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await orderSeeder(dbConnection) + await swapSeeder(dbConnection) const manager = dbConnection.manager @@ -276,14 +266,9 @@ describe("/admin/orders", () => { describe("POST /admin/orders/:id/swaps", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await orderSeeder(dbConnection) - await claimSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await orderSeeder(dbConnection) + await claimSeeder(dbConnection) }) afterEach(async () => { @@ -318,14 +303,9 @@ describe("/admin/orders", () => { describe("POST /admin/orders/:id/claims", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await orderSeeder(dbConnection) - await claimSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await orderSeeder(dbConnection) + await claimSeeder(dbConnection) }) afterEach(async () => { @@ -1216,14 +1196,9 @@ describe("/admin/orders", () => { describe("POST /admin/orders/:id/claims", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await orderSeeder(dbConnection) - await swapSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await orderSeeder(dbConnection) + await swapSeeder(dbConnection) }) afterEach(async () => { @@ -1272,21 +1247,16 @@ describe("/admin/orders", () => { describe("POST /admin/orders/:id/return", () => { let rrId beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await orderSeeder(dbConnection) + await adminSeeder(dbConnection) + await orderSeeder(dbConnection) - const created = dbConnection.manager.create(ReturnReason, { - value: "too_big", - label: "Too Big", - }) - const result = await dbConnection.manager.save(created) + const created = dbConnection.manager.create(ReturnReason, { + value: "too_big", + label: "Too Big", + }) + const result = await dbConnection.manager.save(created) - rrId = result.id - } catch (err) { - console.log(err) - throw err - } + rrId = result.id }) afterEach(async () => { @@ -1392,17 +1362,12 @@ describe("/admin/orders", () => { describe("GET /admin/orders", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - // Manually insert date for filtering - const createdAt = new Date("26 January 1997 12:00 UTC") - await orderSeeder(dbConnection, { - created_at: createdAt.toISOString(), - }) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + // Manually insert date for filtering + const createdAt = new Date("26 January 1997 12:00 UTC") + await orderSeeder(dbConnection, { + created_at: createdAt.toISOString(), + }) }) afterEach(async () => { @@ -1521,16 +1486,18 @@ describe("/admin/orders", () => { expect(response.status).toEqual(200) expect(response.data.count).toEqual(2) - expect(response.data.orders).toEqual(expect.arrayContaining([ - expect.objectContaining({ - id: "test-order", - shipping_address: expect.objectContaining({ first_name: "lebron" }), - }), - expect.objectContaining({ - id: "discount-order", - shipping_address: expect.objectContaining({ first_name: "lebron" }), - }), - ])) + expect(response.data.orders).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + id: "test-order", + shipping_address: expect.objectContaining({ first_name: "lebron" }), + }), + expect.objectContaining({ + id: "discount-order", + shipping_address: expect.objectContaining({ first_name: "lebron" }), + }), + ]) + ) }) it("successfully lists orders with greater than", async () => { @@ -1727,14 +1694,9 @@ describe("/admin/orders", () => { describe("POST /admin/orders/:id/swaps", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await orderSeeder(dbConnection) - await swapSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await orderSeeder(dbConnection) + await swapSeeder(dbConnection) }) afterEach(async () => { @@ -2137,33 +2099,29 @@ describe("/admin/orders", () => { }) it("Only allows canceling swap after canceling fulfillments", async () => { - try { - const swap_id = "swap-w-f" + const swap_id = "swap-w-f" - const swap = await callGet({ - path: `/admin/swaps/${swap_id}`, - get: "swap", - }) + const swap = await callGet({ + path: `/admin/swaps/${swap_id}`, + get: "swap", + }) - const { order_id } = swap + const { order_id } = swap - const expectCancelToReturn = partial(expectPostCallToReturn, { - path: `/admin/orders/${order_id}/swaps/${swap_id}/cancel`, - }) + const expectCancelToReturn = partial(expectPostCallToReturn, { + path: `/admin/orders/${order_id}/swaps/${swap_id}/cancel`, + }) - await expectCancelToReturn({ code: 400 }) + await expectCancelToReturn({ code: 400 }) - await expectAllPostCallsToReturn({ - code: 200, - col: swap.fulfillments, - pathf: (f) => - `/admin/orders/${order_id}/swaps/${swap_id}/fulfillments/${f.id}/cancel`, - }) + await expectAllPostCallsToReturn({ + code: 200, + col: swap.fulfillments, + pathf: (f) => + `/admin/orders/${order_id}/swaps/${swap_id}/fulfillments/${f.id}/cancel`, + }) - await expectCancelToReturn({ code: 200 }) - } catch (e) { - console.log(e) - } + await expectCancelToReturn({ code: 200 }) }) it("Only allows canceling swap after canceling return", async () => { diff --git a/integration-tests/api/__tests__/admin/price-list.js b/integration-tests/api/__tests__/admin/price-list.js index c5520d7336..fb8479ef89 100644 --- a/integration-tests/api/__tests__/admin/price-list.js +++ b/integration-tests/api/__tests__/admin/price-list.js @@ -37,14 +37,9 @@ describe("/admin/price-lists", () => { describe("POST /admin/price-list", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - await productSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) + await productSeeder(dbConnection) }) afterEach(async () => { @@ -116,14 +111,9 @@ describe("/admin/price-lists", () => { describe("GET /admin/price-lists", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await productSeeder(dbConnection) - await priceListSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await productSeeder(dbConnection) + await priceListSeeder(dbConnection) }) afterEach(async () => { @@ -372,15 +362,10 @@ describe("/admin/price-lists", () => { describe("POST /admin/price-lists/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await customerSeeder(dbConnection) - await productSeeder(dbConnection) - await priceListSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await customerSeeder(dbConnection) + await productSeeder(dbConnection) + await priceListSeeder(dbConnection) }) afterEach(async () => { @@ -659,14 +644,9 @@ describe("/admin/price-lists", () => { describe("POST /admin/price-lists/:id/prices/batch", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await productSeeder(dbConnection) - await priceListSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await productSeeder(dbConnection) + await priceListSeeder(dbConnection) }) afterEach(async () => { @@ -949,14 +929,9 @@ describe("/admin/price-lists", () => { describe("DELETE /admin/price-lists/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await productSeeder(dbConnection) - await priceListSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await productSeeder(dbConnection) + await priceListSeeder(dbConnection) }) afterEach(async () => { @@ -1001,14 +976,9 @@ describe("/admin/price-lists", () => { describe("tests cascade on delete", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await productSeeder(dbConnection) - await priceListSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await productSeeder(dbConnection) + await priceListSeeder(dbConnection) }) afterEach(async () => { @@ -1045,14 +1015,9 @@ describe("/admin/price-lists", () => { describe("DELETE /admin/price-lists/:id/prices/batch", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await productSeeder(dbConnection) - await priceListSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await productSeeder(dbConnection) + await priceListSeeder(dbConnection) }) afterEach(async () => { @@ -1102,59 +1067,54 @@ describe("/admin/price-lists", () => { describe("GET /admin/price-lists/:id/products", () => { let tag beforeEach(async () => { - try { - await adminSeeder(dbConnection) + await adminSeeder(dbConnection) - await simpleProductFactory( - dbConnection, - { - id: "test-prod-1", - title: "MedusaHeadphones", - variants: [{ id: "test-variant-1" }, { id: "test-variant-2" }], - }, - 1 - ) + await simpleProductFactory( + dbConnection, + { + id: "test-prod-1", + title: "MedusaHeadphones", + variants: [{ id: "test-variant-1" }, { id: "test-variant-2" }], + }, + 1 + ) - const prod = await simpleProductFactory( - dbConnection, - { - id: "test-prod-2", - tags: ["test-tag"], - variants: [{ id: "test-variant-3" }, { id: "test-variant-4" }], - }, - 2 - ) + const prod = await simpleProductFactory( + dbConnection, + { + id: "test-prod-2", + tags: ["test-tag"], + variants: [{ id: "test-variant-3" }, { id: "test-variant-4" }], + }, + 2 + ) - tag = prod.tags[0].id + tag = prod.tags[0].id - await simpleProductFactory( - dbConnection, - { - id: "test-prod-3", - variants: [{ id: "test-variant-5" }], - }, - 3 - ) + await simpleProductFactory( + dbConnection, + { + id: "test-prod-3", + variants: [{ id: "test-variant-5" }], + }, + 3 + ) - await simplePriceListFactory(dbConnection, { - id: "test-list", - customer_groups: ["test-group"], - prices: [ - { variant_id: "test-variant-1", currency_code: "usd", amount: 150 }, - { variant_id: "test-variant-4", currency_code: "usd", amount: 150 }, - ], - }) - await simplePriceListFactory(dbConnection, { - id: "test-list-2", - prices: [ - { variant_id: "test-variant-1", currency_code: "usd", amount: 200 }, - { variant_id: "test-variant-4", currency_code: "usd", amount: 200 }, - ], - }) - } catch (err) { - console.log(err) - throw err - } + await simplePriceListFactory(dbConnection, { + id: "test-list", + customer_groups: ["test-group"], + prices: [ + { variant_id: "test-variant-1", currency_code: "usd", amount: 150 }, + { variant_id: "test-variant-4", currency_code: "usd", amount: 150 }, + ], + }) + await simplePriceListFactory(dbConnection, { + id: "test-list-2", + prices: [ + { variant_id: "test-variant-1", currency_code: "usd", amount: 200 }, + { variant_id: "test-variant-4", currency_code: "usd", amount: 200 }, + ], + }) }) afterEach(async () => { @@ -1278,61 +1238,56 @@ describe("/admin/price-lists", () => { } beforeEach(async () => { - try { - await adminSeeder(dbConnection) + await adminSeeder(dbConnection) - product1 = await simpleProductFactory( - dbConnection, - { - id: "test-prod-1", - title: "some product", - variants: [ - { - id: `simple-test-variant-${Math.random() * 1000}`, - title: "Test", - prices: [{ currency: "usd", amount: 100 }], - }, - { - id: `simple-test-variant-${Math.random() * 1000}`, - title: "Test 2", - prices: [{ currency: "usd", amount: 200 }], - }, - ], - }, - 1 - ) - - product2 = await simpleProductFactory( - dbConnection, - { - id: "test-prod-2", - title: "some product 2", - }, - 2 - ) - - await simplePriceListFactory(dbConnection, { - id: "test-list", - customer_groups: ["test-group"], - prices: [ - ...product1.variants.map((variant, i) => ({ - id: getCustomPriceIdFromVariant(variant.id, i), - variant_id: variant.id, - currency_code: "usd", - amount: (i + 1) * 150, - })), - ...product2.variants.map((variant, i) => ({ - id: getCustomPriceIdFromVariant(variant.id, i), - variant_id: variant.id, - currency_code: "usd", - amount: (i + 1) * 150, - })), + product1 = await simpleProductFactory( + dbConnection, + { + id: "test-prod-1", + title: "some product", + variants: [ + { + id: `simple-test-variant-${Math.random() * 1000}`, + title: "Test", + prices: [{ currency: "usd", amount: 100 }], + }, + { + id: `simple-test-variant-${Math.random() * 1000}`, + title: "Test 2", + prices: [{ currency: "usd", amount: 200 }], + }, ], - }) - } catch (err) { - console.log(err) - throw err - } + }, + 1 + ) + + product2 = await simpleProductFactory( + dbConnection, + { + id: "test-prod-2", + title: "some product 2", + }, + 2 + ) + + await simplePriceListFactory(dbConnection, { + id: "test-list", + customer_groups: ["test-group"], + prices: [ + ...product1.variants.map((variant, i) => ({ + id: getCustomPriceIdFromVariant(variant.id, i), + variant_id: variant.id, + currency_code: "usd", + amount: (i + 1) * 150, + })), + ...product2.variants.map((variant, i) => ({ + id: getCustomPriceIdFromVariant(variant.id, i), + variant_id: variant.id, + currency_code: "usd", + amount: (i + 1) * 150, + })), + ], + }) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/product-tag.js b/integration-tests/api/__tests__/admin/product-tag.js index b2cfffdfb2..d1a45f5115 100644 --- a/integration-tests/api/__tests__/admin/product-tag.js +++ b/integration-tests/api/__tests__/admin/product-tag.js @@ -28,13 +28,8 @@ describe("/admin/product-tags", () => { describe("GET /admin/product-tags", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/product-type.js b/integration-tests/api/__tests__/admin/product-type.js index 23dad55c81..1bf57e717d 100644 --- a/integration-tests/api/__tests__/admin/product-type.js +++ b/integration-tests/api/__tests__/admin/product-type.js @@ -28,13 +28,8 @@ describe("/admin/product-types", () => { describe("GET /admin/product-types", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) }) afterEach(async () => { @@ -62,10 +57,7 @@ describe("/admin/product-types", () => { updated_at: expect.any(String), } - expect(res.data.product_types).toMatchSnapshot([ - typeMatch, - typeMatch, - ]) + expect(res.data.product_types).toMatchSnapshot([typeMatch, typeMatch]) }) it("returns a list of product types matching free text search param", async () => { @@ -90,13 +82,11 @@ describe("/admin/product-types", () => { // The value of the type should match the search param expect(res.data.product_types.map((pt) => pt.value)).toEqual([ - "test-type-new" + "test-type-new", ]) // Should only return one type as there is only one match to the search param - expect(res.data.product_types).toMatchSnapshot([ - typeMatch - ]) + expect(res.data.product_types).toMatchSnapshot([typeMatch]) }) }) }) diff --git a/integration-tests/api/__tests__/admin/product.js b/integration-tests/api/__tests__/admin/product.js index 51e11878dd..09d78ea7ca 100644 --- a/integration-tests/api/__tests__/admin/product.js +++ b/integration-tests/api/__tests__/admin/product.js @@ -34,13 +34,8 @@ describe("/admin/products", () => { describe("GET /admin/products", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) }) afterEach(async () => { @@ -852,13 +847,8 @@ describe("/admin/products", () => { describe("POST /admin/products", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) }) afterEach(async () => { @@ -1427,13 +1417,8 @@ describe("/admin/products", () => { describe("GET /admin/products/:id/variants", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) }) afterEach(async () => { @@ -1481,14 +1466,9 @@ describe("/admin/products", () => { describe("updates a variant's default prices (ignores prices associated with a Price List)", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - await priceListSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) + await priceListSeeder(dbConnection) }) afterEach(async () => { @@ -1757,13 +1737,8 @@ describe("/admin/products", () => { describe("testing for soft-deletion + uniqueness on handles, collection and variant properties", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) }) afterEach(async () => { @@ -2256,13 +2231,8 @@ describe("/admin/products", () => { describe("GET /admin/products/tag-usage", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/region.js b/integration-tests/api/__tests__/admin/region.js index fca514edb2..9ee9b923e4 100644 --- a/integration-tests/api/__tests__/admin/region.js +++ b/integration-tests/api/__tests__/admin/region.js @@ -27,23 +27,18 @@ describe("/admin/regions", () => { describe("Remove region from country on delete", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - const manager = dbConnection.manager - await manager.insert(Region, { - id: "test-region", - name: "Test Region", - currency_code: "usd", - tax_rate: 0, - }) + await adminSeeder(dbConnection) + const manager = dbConnection.manager + await manager.insert(Region, { + id: "test-region", + name: "Test Region", + currency_code: "usd", + tax_rate: 0, + }) - await manager.query( - `UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'` - ) - } catch (err) { - console.log(err) - throw err - } + await manager.query( + `UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'` + ) }) afterEach(async () => { @@ -203,23 +198,18 @@ describe("/admin/regions", () => { describe("DELETE /admin/regions/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - const manager = dbConnection.manager - await manager.insert(Region, { - id: "test-region", - name: "Test Region", - currency_code: "usd", - tax_rate: 0, - }) + await adminSeeder(dbConnection) + const manager = dbConnection.manager + await manager.insert(Region, { + id: "test-region", + name: "Test Region", + currency_code: "usd", + tax_rate: 0, + }) - await manager.query( - `UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'` - ) - } catch (err) { - console.log(err) - throw err - } + await manager.query( + `UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'` + ) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/return-reason.js b/integration-tests/api/__tests__/admin/return-reason.js index 4e180e23b6..d9eac8270e 100644 --- a/integration-tests/api/__tests__/admin/return-reason.js +++ b/integration-tests/api/__tests__/admin/return-reason.js @@ -27,12 +27,7 @@ describe("/admin/return-reasons", () => { describe("POST /admin/return-reasons", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/returns.js b/integration-tests/api/__tests__/admin/returns.js index a8656cad7d..9e18caff20 100644 --- a/integration-tests/api/__tests__/admin/returns.js +++ b/integration-tests/api/__tests__/admin/returns.js @@ -31,20 +31,15 @@ describe("/admin/returns", () => { let rrId beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await orderSeeder(dbConnection) + await adminSeeder(dbConnection) + await orderSeeder(dbConnection) - const created = dbConnection.manager.create(ReturnReason, { - value: "too_big", - label: "Too Big", - }) - const resultRR = await dbConnection.manager.save(created) - rrId = resultRR.id - } catch (err) { - console.log(err) - throw err - } + const created = dbConnection.manager.create(ReturnReason, { + value: "too_big", + label: "Too Big", + }) + const resultRR = await dbConnection.manager.save(created) + rrId = resultRR.id }) afterEach(async () => { @@ -231,9 +226,9 @@ describe("/admin/returns", () => { }, ], return_shipping: { - option_id: "test-option", - price: 0, - } + option_id: "test-option", + price: 0, + }, }, { headers: { diff --git a/integration-tests/api/__tests__/admin/sales-channels.js b/integration-tests/api/__tests__/admin/sales-channels.js index 7ffebc6ace..0cc5d3f6bd 100644 --- a/integration-tests/api/__tests__/admin/sales-channels.js +++ b/integration-tests/api/__tests__/admin/sales-channels.js @@ -52,15 +52,11 @@ describe("sales channels", () => { let salesChannel beforeEach(async () => { - try { - await adminSeeder(dbConnection) - salesChannel = await simpleSalesChannelFactory(dbConnection, { - name: "test name", - description: "test description", - }) - } catch (e) { - console.error(e) - } + await adminSeeder(dbConnection) + salesChannel = await simpleSalesChannelFactory(dbConnection, { + name: "test name", + description: "test description", + }) }) afterEach(async () => { @@ -92,19 +88,15 @@ describe("sales channels", () => { let salesChannel2 beforeEach(async () => { - try { - await adminSeeder(dbConnection) - salesChannel1 = await simpleSalesChannelFactory(dbConnection, { - name: "test name", - description: "test description", - }) - salesChannel2 = await simpleSalesChannelFactory(dbConnection, { - name: "test name 2", - description: "test description 2", - }) - } catch (e) { - console.error(e) - } + await adminSeeder(dbConnection) + salesChannel1 = await simpleSalesChannelFactory(dbConnection, { + name: "test name", + description: "test description", + }) + salesChannel2 = await simpleSalesChannelFactory(dbConnection, { + name: "test name 2", + description: "test description 2", + }) }) afterEach(async () => { @@ -207,15 +199,11 @@ describe("sales channels", () => { let sc beforeEach(async () => { - try { - await adminSeeder(dbConnection) - sc = await simpleSalesChannelFactory(dbConnection, { - name: "test name", - description: "test description", - }) - } catch (err) { - console.log(err) - } + await adminSeeder(dbConnection) + sc = await simpleSalesChannelFactory(dbConnection, { + name: "test name", + description: "test description", + }) }) afterEach(async () => { @@ -256,11 +244,7 @@ describe("sales channels", () => { describe("POST /admin/sales-channels", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - } catch (e) { - console.error(e) - } + await adminSeeder(dbConnection) }) afterEach(async () => { @@ -324,21 +308,17 @@ describe("sales channels", () => { let salesChannel beforeEach(async () => { - try { - await adminSeeder(dbConnection) - salesChannel = await simpleSalesChannelFactory(dbConnection, { - name: "test name", - description: "test description", - }) + await adminSeeder(dbConnection) + salesChannel = await simpleSalesChannelFactory(dbConnection, { + name: "test name", + description: "test description", + }) - await simpleSalesChannelFactory(dbConnection, { - name: "Default channel", - id: "test-channel", - is_default: true, - }) - } catch (e) { - console.error(e) - } + await simpleSalesChannelFactory(dbConnection, { + name: "Default channel", + id: "test-channel", + is_default: true, + }) }) afterEach(async () => { @@ -454,18 +434,14 @@ describe("sales channels", () => { describe("GET /admin/orders/:id", () => { let order beforeEach(async () => { - try { - await adminSeeder(dbConnection) + await adminSeeder(dbConnection) - order = await simpleOrderFactory(dbConnection, { - sales_channel: { - name: "test name", - description: "test description", - }, - }) - } catch (err) { - console.log(err) - } + order = await simpleOrderFactory(dbConnection, { + sales_channel: { + name: "test name", + description: "test description", + }, + }) }) afterEach(async () => { @@ -495,18 +471,14 @@ describe("sales channels", () => { describe("GET /admin/orders?expand=sales_channels", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) + await adminSeeder(dbConnection) - await simpleOrderFactory(dbConnection, { - sales_channel: { - name: "test name", - description: "test description", - }, - }) - } catch (err) { - console.log(err) - } + await simpleOrderFactory(dbConnection, { + sales_channel: { + name: "test name", + description: "test description", + }, + }) }) afterEach(async () => { @@ -537,24 +509,20 @@ describe("sales channels", () => { describe("GET /admin/product/:id", () => { let product beforeEach(async () => { - try { - await adminSeeder(dbConnection) + await adminSeeder(dbConnection) - product = await simpleProductFactory(dbConnection, { - sales_channels: [ - { - name: "webshop", - description: "Webshop sales channel", - }, - { - name: "amazon", - description: "Amazon sales channel", - }, - ], - }) - } catch (err) { - console.log(err) - } + product = await simpleProductFactory(dbConnection, { + sales_channels: [ + { + name: "webshop", + description: "Webshop sales channel", + }, + { + name: "amazon", + description: "Amazon sales channel", + }, + ], + }) }) afterEach(async () => { @@ -589,24 +557,20 @@ describe("sales channels", () => { describe("GET /admin/products?expand[]=sales_channels", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) + await adminSeeder(dbConnection) - await simpleProductFactory(dbConnection, { - sales_channels: [ - { - name: "webshop", - description: "Webshop sales channel", - }, - { - name: "amazon", - description: "Amazon sales channel", - }, - ], - }) - } catch (err) { - console.log(err) - } + await simpleProductFactory(dbConnection, { + sales_channels: [ + { + name: "webshop", + description: "Webshop sales channel", + }, + { + name: "amazon", + description: "Amazon sales channel", + }, + ], + }) }) afterEach(async () => { @@ -645,20 +609,16 @@ describe("sales channels", () => { let product beforeEach(async () => { - try { - await adminSeeder(dbConnection) - product = await simpleProductFactory(dbConnection, { - id: "product_1", - title: "test title", - }) - salesChannel = await simpleSalesChannelFactory(dbConnection, { - name: "test name", - description: "test description", - products: [product], - }) - } catch (e) { - console.error(e) - } + await adminSeeder(dbConnection) + product = await simpleProductFactory(dbConnection, { + id: "product_1", + title: "test title", + }) + salesChannel = await simpleSalesChannelFactory(dbConnection, { + name: "test name", + description: "test description", + products: [product], + }) }) afterEach(async () => { @@ -730,19 +690,15 @@ describe("sales channels", () => { let product beforeEach(async () => { - try { - await adminSeeder(dbConnection) - salesChannel = await simpleSalesChannelFactory(dbConnection, { - name: "test name", - description: "test description", - }) - product = await simpleProductFactory(dbConnection, { - id: "product_1", - title: "test title", - }) - } catch (e) { - console.error(e) - } + await adminSeeder(dbConnection) + salesChannel = await simpleSalesChannelFactory(dbConnection, { + name: "test name", + description: "test description", + }) + product = await simpleProductFactory(dbConnection, { + id: "product_1", + title: "test title", + }) }) afterEach(async () => { @@ -798,19 +754,14 @@ describe("sales channels", () => { let order beforeEach(async () => { - try { - await adminSeeder(dbConnection) - order = await simpleOrderFactory(dbConnection, { - sales_channel: { - name: "test name", - description: "test description", - }, - }) - await orderSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + order = await simpleOrderFactory(dbConnection, { + sales_channel: { + name: "test name", + description: "test description", + }, + }) + await orderSeeder(dbConnection) }) afterEach(async () => { @@ -850,19 +801,14 @@ describe("sales channels", () => { let salesChannel beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - const product = await simpleProductFactory(dbConnection, productData) - salesChannel = await simpleSalesChannelFactory(dbConnection, { - name: "test name", - description: "test description", - products: [product], - }) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) + const product = await simpleProductFactory(dbConnection, productData) + salesChannel = await simpleSalesChannelFactory(dbConnection, { + name: "test name", + description: "test description", + products: [product], + }) }) afterEach(async () => { @@ -900,17 +846,12 @@ describe("sales channels", () => { let salesChannel beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - salesChannel = await simpleSalesChannelFactory(dbConnection, { - name: "test name", - description: "test description", - }) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) + salesChannel = await simpleSalesChannelFactory(dbConnection, { + name: "test name", + description: "test description", + }) }) afterEach(async () => { @@ -965,17 +906,12 @@ describe("sales channels", () => { let salesChannel beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - salesChannel = await simpleSalesChannelFactory(dbConnection, { - name: "test name", - description: "test description", - }) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) + salesChannel = await simpleSalesChannelFactory(dbConnection, { + name: "test name", + description: "test description", + }) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/shipping-options.js b/integration-tests/api/__tests__/admin/shipping-options.js index 031deaf39a..9872dc8582 100644 --- a/integration-tests/api/__tests__/admin/shipping-options.js +++ b/integration-tests/api/__tests__/admin/shipping-options.js @@ -32,13 +32,8 @@ describe("/admin/shipping-options", () => { describe("POST /admin/shipping-options/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await shippingOptionSeeder(dbConnection) - } catch (err) { - console.error(err) - throw err - } + await adminSeeder(dbConnection) + await shippingOptionSeeder(dbConnection) }) afterEach(async () => { @@ -254,40 +249,35 @@ describe("/admin/shipping-options", () => { let payload beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await shippingOptionSeeder(dbConnection) + await adminSeeder(dbConnection) + await shippingOptionSeeder(dbConnection) - const api = useApi() - await api.post( - `/admin/regions/region`, - { - fulfillment_providers: ["test-ful"], + const api = useApi() + await api.post( + `/admin/regions/region`, + { + fulfillment_providers: ["test-ful"], + }, + { + headers: { + Authorization: "Bearer test_token", }, - { - headers: { - Authorization: "Bearer test_token", - }, - } - ) - - const manager = dbConnection.manager - const defaultProfile = await manager.findOne(ShippingProfile, { - type: "default", - }) - - payload = { - name: "Test option", - amount: 100, - price_type: "flat_rate", - region_id: "region", - provider_id: "test-ful", - data: {}, - profile_id: defaultProfile.id, } - } catch (err) { - console.error(err) - throw err + ) + + const manager = dbConnection.manager + const defaultProfile = await manager.findOne(ShippingProfile, { + type: "default", + }) + + payload = { + name: "Test option", + amount: 100, + price_type: "flat_rate", + region_id: "region", + provider_id: "test-ful", + data: {}, + profile_id: defaultProfile.id, } }) @@ -385,13 +375,8 @@ describe("/admin/shipping-options", () => { }) describe("GET /admin/shipping-options", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await shippingOptionSeeder(dbConnection) - } catch (err) { - console.error(err) - throw err - } + await adminSeeder(dbConnection) + await shippingOptionSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/swaps.js b/integration-tests/api/__tests__/admin/swaps.js index cf53d3c25e..ecda8da1af 100644 --- a/integration-tests/api/__tests__/admin/swaps.js +++ b/integration-tests/api/__tests__/admin/swaps.js @@ -28,13 +28,9 @@ describe("/admin/swaps", () => { describe("GET /admin/swaps/:id", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await orderSeeder(dbConnection) - await swapSeeder(dbConnection) - } catch (err) { - throw err - } + await adminSeeder(dbConnection) + await orderSeeder(dbConnection) + await swapSeeder(dbConnection) }) afterEach(async () => { @@ -106,13 +102,9 @@ describe("/admin/swaps", () => { describe("GET /admin/swaps/", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await orderSeeder(dbConnection) - await swapSeeder(dbConnection) - } catch (err) { - throw err - } + await adminSeeder(dbConnection) + await orderSeeder(dbConnection) + await swapSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/admin/variant.js b/integration-tests/api/__tests__/admin/variant.js index a0244141c1..3f8934d830 100644 --- a/integration-tests/api/__tests__/admin/variant.js +++ b/integration-tests/api/__tests__/admin/variant.js @@ -28,13 +28,8 @@ describe("/admin/products", () => { describe("GET /admin/product-variants", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/batch-jobs/api.js b/integration-tests/api/__tests__/batch-jobs/api.js index dbf350009f..3ce67820fb 100644 --- a/integration-tests/api/__tests__/batch-jobs/api.js +++ b/integration-tests/api/__tests__/batch-jobs/api.js @@ -18,42 +18,37 @@ const adminReqConfig = { } const setupJobDb = async (dbConnection) => { - try { - await adminSeeder(dbConnection) - await userSeeder(dbConnection) + await adminSeeder(dbConnection) + await userSeeder(dbConnection) - await simpleBatchJobFactory(dbConnection, { - id: "job_1", - type: "product-export", - created_by: "admin_user", - }) - await simpleBatchJobFactory(dbConnection, { - id: "job_2", - type: "product-export", - created_by: "admin_user", - }) - await simpleBatchJobFactory(dbConnection, { - id: "job_3", - type: "product-export", - created_by: "admin_user", - }) - await simpleBatchJobFactory(dbConnection, { - id: "job_4", - type: "product-export", - status: "awaiting_confirmation", - created_by: "member-user", - }) - await simpleBatchJobFactory(dbConnection, { - id: "job_5", - type: "product-export", - status: "completed", - completed_at: "2022-06-27T22:00:00.000Z", - created_by: "admin_user", - }) - } catch (err) { - console.log(err) - throw err - } + await simpleBatchJobFactory(dbConnection, { + id: "job_1", + type: "product-export", + created_by: "admin_user", + }) + await simpleBatchJobFactory(dbConnection, { + id: "job_2", + type: "product-export", + created_by: "admin_user", + }) + await simpleBatchJobFactory(dbConnection, { + id: "job_3", + type: "product-export", + created_by: "admin_user", + }) + await simpleBatchJobFactory(dbConnection, { + id: "job_4", + type: "product-export", + status: "awaiting_confirmation", + created_by: "member-user", + }) + await simpleBatchJobFactory(dbConnection, { + id: "job_5", + type: "product-export", + status: "completed", + completed_at: "2022-06-27T22:00:00.000Z", + created_by: "admin_user", + }) } describe("/admin/batch-jobs", () => { @@ -251,18 +246,13 @@ describe("/admin/batch-jobs", () => { describe("POST /admin/batch-jobs/:id/cancel", () => { beforeEach(async () => { - try { - await setupJobDb(dbConnection) - await simpleBatchJobFactory(dbConnection, { - id: "job_complete", - type: "product-export", - created_by: "admin_user", - completed_at: new Date(), - }) - } catch (e) { - console.log(e) - throw e - } + await setupJobDb(dbConnection) + await simpleBatchJobFactory(dbConnection, { + id: "job_complete", + type: "product-export", + created_by: "admin_user", + completed_at: new Date(), + }) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/batch-jobs/order/export.js b/integration-tests/api/__tests__/batch-jobs/order/export.js index 3e4421f6cb..4c43a71046 100644 --- a/integration-tests/api/__tests__/batch-jobs/order/export.js +++ b/integration-tests/api/__tests__/batch-jobs/order/export.js @@ -47,14 +47,9 @@ describe("Batchjob with type order-export", () => { }) beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await userSeeder(dbConnection) - await orderSeeder(dbConnection) - } catch (e) { - console.log(e) - throw e - } + await adminSeeder(dbConnection) + await userSeeder(dbConnection) + await orderSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/batch-jobs/product/export.js b/integration-tests/api/__tests__/batch-jobs/product/export.js index 8722da43c7..e37918e6f1 100644 --- a/integration-tests/api/__tests__/batch-jobs/product/export.js +++ b/integration-tests/api/__tests__/batch-jobs/product/export.js @@ -47,14 +47,9 @@ describe("Batch job of product-export type", () => { }) beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - await userSeeder(dbConnection) - } catch (e) { - console.log(e) - throw e - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) + await userSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/claims/index.js b/integration-tests/api/__tests__/claims/index.js index d7bfaed911..513bd4d970 100644 --- a/integration-tests/api/__tests__/claims/index.js +++ b/integration-tests/api/__tests__/claims/index.js @@ -24,12 +24,8 @@ describe("Claims", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - dbConnection = await initDb({ cwd }) - medusaProcess = await setupServer({ cwd }) - } catch (error) { - console.log(error) - } + dbConnection = await initDb({ cwd }) + medusaProcess = await setupServer({ cwd }) }) afterAll(async () => { diff --git a/integration-tests/api/__tests__/line-item-adjustments/ff-sales-channel.js b/integration-tests/api/__tests__/line-item-adjustments/ff-sales-channel.js index be8dbb9baf..cfd63a1f39 100644 --- a/integration-tests/api/__tests__/line-item-adjustments/ff-sales-channel.js +++ b/integration-tests/api/__tests__/line-item-adjustments/ff-sales-channel.js @@ -20,17 +20,13 @@ describe("Line Item - Sales Channel", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - const [process, connection] = await startServerWithEnvironment({ - cwd, - env: { MEDUSA_FF_SALES_CHANNELS: true }, - verbose: false, - }) - dbConnection = connection - medusaProcess = process - } catch (error) { - console.log(error) - } + const [process, connection] = await startServerWithEnvironment({ + cwd, + env: { MEDUSA_FF_SALES_CHANNELS: true }, + verbose: false, + }) + dbConnection = connection + medusaProcess = process }) afterAll(async () => { @@ -40,53 +36,48 @@ describe("Line Item - Sales Channel", () => { }) beforeEach(async () => { - try { - await simpleProductFactory(dbConnection, { - id: "test-product-in-sales-channel", - title: "test product belonging to a channel", - sales_channels: [ - { - id: "main-sales-channel", - name: "Main sales channel", - description: "Main sales channel", - is_disabled: false, - }, - ], - variants: [ - { - id: "test-variant-sales-channel", - title: "test variant in sales channel", - product_id: "test-product-in-sales-channel", - inventory_quantity: 1000, - prices: [ - { - currency: "usd", - amount: 59, - }, - ], - }, - ], - }) - - await simpleProductFactory(dbConnection, { - id: "test-product-no-sales-channel", - variants: [ - { - id: "test-variant-no-sales-channel", - }, - ], - }) - - await simpleCartFactory(dbConnection, { - id: "test-cart-with-sales-channel", - sales_channel: { + await simpleProductFactory(dbConnection, { + id: "test-product-in-sales-channel", + title: "test product belonging to a channel", + sales_channels: [ + { id: "main-sales-channel", + name: "Main sales channel", + description: "Main sales channel", + is_disabled: false, }, - }) - } catch (err) { - console.log(err) - throw err - } + ], + variants: [ + { + id: "test-variant-sales-channel", + title: "test variant in sales channel", + product_id: "test-product-in-sales-channel", + inventory_quantity: 1000, + prices: [ + { + currency: "usd", + amount: 59, + }, + ], + }, + ], + }) + + await simpleProductFactory(dbConnection, { + id: "test-product-no-sales-channel", + variants: [ + { + id: "test-variant-no-sales-channel", + }, + ], + }) + + await simpleCartFactory(dbConnection, { + id: "test-cart-with-sales-channel", + sales_channel: { + id: "main-sales-channel", + }, + }) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/line-item-adjustments/index.js b/integration-tests/api/__tests__/line-item-adjustments/index.js index 5a9d4cc601..c48cffbef5 100644 --- a/integration-tests/api/__tests__/line-item-adjustments/index.js +++ b/integration-tests/api/__tests__/line-item-adjustments/index.js @@ -22,12 +22,8 @@ describe("Line Item Adjustments", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - dbConnection = await initDb({ cwd }) - medusaProcess = await setupServer({ cwd }) - } catch (error) { - console.log(error) - } + dbConnection = await initDb({ cwd }) + medusaProcess = await setupServer({ cwd }) }) afterAll(async () => { @@ -41,60 +37,55 @@ describe("Line Item Adjustments", () => { discount, lineItemId = "line-test" beforeEach(async () => { - try { - await cartSeeder(dbConnection) - discount = await simpleDiscountFactory(dbConnection, { - code: "MEDUSATEST", - id: "discount-test", - rule: { - value: 100, - type: "fixed", - allocation: "total", - }, - regions: ["test-region"], - }) - cart = await simpleCartFactory( - dbConnection, - { - customer: "test-customer", - id: "cart-test", - line_items: [ - { - id: lineItemId, - variant_id: "test-variant", - cart_id: "cart-test", - unit_price: 1000, - quantity: 1, - adjustments: [ - { - amount: 10, - discount_id: discount.id, - description: "discount", - item_id: lineItemId, - }, - ], - }, - ], - region: "test-region", - shipping_address: { - address_1: "test", - country_code: "us", - first_name: "chris", - last_name: "rock", - postal_code: "101", + await cartSeeder(dbConnection) + discount = await simpleDiscountFactory(dbConnection, { + code: "MEDUSATEST", + id: "discount-test", + rule: { + value: 100, + type: "fixed", + allocation: "total", + }, + regions: ["test-region"], + }) + cart = await simpleCartFactory( + dbConnection, + { + customer: "test-customer", + id: "cart-test", + line_items: [ + { + id: lineItemId, + variant_id: "test-variant", + cart_id: "cart-test", + unit_price: 1000, + quantity: 1, + adjustments: [ + { + amount: 10, + discount_id: discount.id, + description: "discount", + item_id: lineItemId, + }, + ], }, - shipping_methods: [ - { - shipping_option: "test-option", - }, - ], + ], + region: "test-region", + shipping_address: { + address_1: "test", + country_code: "us", + first_name: "chris", + last_name: "rock", + postal_code: "101", }, - 100 - ) - } catch (err) { - console.log(err) - throw err - } + shipping_methods: [ + { + shipping_option: "test-option", + }, + ], + }, + 100 + ) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/price-selection/index.js b/integration-tests/api/__tests__/price-selection/index.js index c0e2ba60d8..58c55f732d 100644 --- a/integration-tests/api/__tests__/price-selection/index.js +++ b/integration-tests/api/__tests__/price-selection/index.js @@ -28,13 +28,8 @@ describe("Promotions", () => { describe("Money amount", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await promotionsSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) + await promotionsSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/returns/index.js b/integration-tests/api/__tests__/returns/index.js index 5e7cfa3b83..5366269a90 100644 --- a/integration-tests/api/__tests__/returns/index.js +++ b/integration-tests/api/__tests__/returns/index.js @@ -23,12 +23,8 @@ describe("/admin/orders", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - dbConnection = await initDb({ cwd }) - medusaProcess = await setupServer({ cwd }) - } catch (error) { - console.log(error) - } + dbConnection = await initDb({ cwd }) + medusaProcess = await setupServer({ cwd }) }) afterAll(async () => { diff --git a/integration-tests/api/__tests__/store/cart.js b/integration-tests/api/__tests__/store/cart.js index a8353e2c4e..0a8648f0d1 100644 --- a/integration-tests/api/__tests__/store/cart.js +++ b/integration-tests/api/__tests__/store/cart.js @@ -46,12 +46,8 @@ describe("/store/carts", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - dbConnection = await initDb({ cwd }) - medusaProcess = await setupServer({ cwd, verbose: false }) - } catch (error) { - console.log(error) - } + dbConnection = await initDb({ cwd }) + medusaProcess = await setupServer({ cwd, verbose: false }) }) afterAll(async () => { @@ -207,13 +203,8 @@ describe("/store/carts", () => { describe("POST /store/carts/:id/line-items", () => { beforeEach(async () => { - try { - await cartSeeder(dbConnection) - await swapSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await cartSeeder(dbConnection) + await swapSeeder(dbConnection) }) afterEach(async () => { @@ -495,57 +486,49 @@ describe("/store/carts", () => { let discountCart let discount beforeEach(async () => { - try { - discount = await simpleDiscountFactory( - dbConnection, - discountData, - 100 - ) - discountCart = await simpleCartFactory( - dbConnection, - { - id: "discount-cart", - customer: "test-customer", - region: "test-region", - shipping_address: { - address_1: "next door", - first_name: "lebron", - last_name: "james", - country_code: "dk", - postal_code: "100", - }, - line_items: [ - { - id: "test-li", - variant_id: "test-variant", - quantity: 1, - unit_price: 100, - adjustments: [ - { - amount: 185, - description: "discount", - discount_id: "medusa-185", - }, - ], - }, - ], - shipping_methods: [ - { - shipping_option: "test-option", - price: 1000, - }, - ], + discount = await simpleDiscountFactory(dbConnection, discountData, 100) + discountCart = await simpleCartFactory( + dbConnection, + { + id: "discount-cart", + customer: "test-customer", + region: "test-region", + shipping_address: { + address_1: "next door", + first_name: "lebron", + last_name: "james", + country_code: "dk", + postal_code: "100", }, - 100 - ) - await dbConnection.manager - .createQueryBuilder() - .relation(Cart, "discounts") - .of(discountCart) - .add(discount) - } catch (err) { - console.log(err) - } + line_items: [ + { + id: "test-li", + variant_id: "test-variant", + quantity: 1, + unit_price: 100, + adjustments: [ + { + amount: 185, + description: "discount", + discount_id: "medusa-185", + }, + ], + }, + ], + shipping_methods: [ + { + shipping_option: "test-option", + price: 1000, + }, + ], + }, + 100 + ) + await dbConnection.manager + .createQueryBuilder() + .relation(Cart, "discounts") + .of(discountCart) + .add(discount) }) afterEach(async () => { @@ -699,13 +682,8 @@ describe("/store/carts", () => { describe("POST /store/carts/:id/line-items/:line_id", () => { beforeEach(async () => { - try { - await cartSeeder(dbConnection) - await swapSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await cartSeeder(dbConnection) + await swapSeeder(dbConnection) }) afterEach(async () => { @@ -901,13 +879,8 @@ describe("/store/carts", () => { describe("POST /store/carts/:id", () => { beforeEach(async () => { - try { - await cartSeeder(dbConnection) - await swapSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await cartSeeder(dbConnection) + await swapSeeder(dbConnection) }) afterEach(async () => { @@ -1738,11 +1711,7 @@ describe("/store/carts", () => { const api = useApi() - try { - await api.post(`/store/carts/swap-cart/complete-cart`) - } catch (error) { - console.log(error) - } + await api.post(`/store/carts/swap-cart/complete-cart`) // check to see if payment is authorized and cart is completed const res = await api.get(`/store/carts/swap-cart`) @@ -1753,35 +1722,31 @@ describe("/store/carts", () => { describe("POST /store/carts/:id/shipping-methods", () => { beforeEach(async () => { - try { - await cartSeeder(dbConnection) - const manager = dbConnection.manager + await cartSeeder(dbConnection) + const manager = dbConnection.manager - const _cart = await manager.create(Cart, { - id: "test-cart-with-cso", - customer_id: "some-customer", - email: "some-customer@email.com", - shipping_address: { - id: "test-shipping-address", - first_name: "lebron", - country_code: "us", - }, - region_id: "test-region", - currency_code: "usd", - type: "swap", - }) + const _cart = await manager.create(Cart, { + id: "test-cart-with-cso", + customer_id: "some-customer", + email: "some-customer@email.com", + shipping_address: { + id: "test-shipping-address", + first_name: "lebron", + country_code: "us", + }, + region_id: "test-region", + currency_code: "usd", + type: "swap", + }) - const cartWithCustomSo = await manager.save(_cart) + const cartWithCustomSo = await manager.save(_cart) - await manager.insert(CustomShippingOption, { - id: "another-cso-test", - cart_id: "test-cart-with-cso", - shipping_option_id: "test-option", - price: 5, - }) - } catch (err) { - console.log(err) - } + await manager.insert(CustomShippingOption, { + id: "another-cso-test", + cart_id: "test-cart-with-cso", + shipping_option_id: "test-option", + price: 5, + }) }) afterEach(async () => { @@ -2059,12 +2024,7 @@ describe("/store/carts", () => { describe("shipping address + region updates", () => { beforeEach(async () => { - try { - await cartSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await cartSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/store/collections.js b/integration-tests/api/__tests__/store/collections.js index b0699271a0..a89d1a05ce 100644 --- a/integration-tests/api/__tests__/store/collections.js +++ b/integration-tests/api/__tests__/store/collections.js @@ -25,12 +25,7 @@ describe("/store/collections", () => { describe("/store/collections/:id", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) }) afterEach(async () => { @@ -55,12 +50,7 @@ describe("/store/collections", () => { describe("/store/collections", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/store/draft-order.js b/integration-tests/api/__tests__/store/draft-order.js index f36bac585f..7a0e8961c9 100644 --- a/integration-tests/api/__tests__/store/draft-order.js +++ b/integration-tests/api/__tests__/store/draft-order.js @@ -27,12 +27,7 @@ describe("/store/carts (draft-orders)", () => { describe("POST /admin/draft-order", () => { beforeEach(async () => { - try { - await draftOrderSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await draftOrderSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/store/product-variants.js b/integration-tests/api/__tests__/store/product-variants.js index a97508f0b0..bb7ffc408b 100644 --- a/integration-tests/api/__tests__/store/product-variants.js +++ b/integration-tests/api/__tests__/store/product-variants.js @@ -26,30 +26,25 @@ describe("/store/variants", () => { describe("GET /store/variants", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) + await productSeeder(dbConnection) - await simpleProductFactory( - dbConnection, - { - title: "prod", - variants: [ - { - title: "test1", - inventory_quantity: 10, - }, - { - title: "test2", - inventory_quantity: 12, - }, - ], - }, - 100 - ) - } catch (err) { - console.log(err) - throw err - } + await simpleProductFactory( + dbConnection, + { + title: "prod", + variants: [ + { + title: "test1", + inventory_quantity: 10, + }, + { + title: "test2", + inventory_quantity: 12, + }, + ], + }, + 100 + ) }) afterEach(async () => { @@ -169,30 +164,25 @@ describe("/store/variants", () => { describe("GET /store/variants advanced pricing", () => { beforeEach(async () => { - try { - await storeProductSeeder(dbConnection) + await storeProductSeeder(dbConnection) - await simpleProductFactory( - dbConnection, - { - title: "prod", - variants: [ - { - title: "test1", - inventory_quantity: 10, - }, - { - title: "test2", - inventory_quantity: 12, - }, - ], - }, - 100 - ) - } catch (err) { - console.log(err) - throw err - } + await simpleProductFactory( + dbConnection, + { + title: "prod", + variants: [ + { + title: "test1", + inventory_quantity: 10, + }, + { + title: "test2", + inventory_quantity: 12, + }, + ], + }, + 100 + ) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/store/products.js b/integration-tests/api/__tests__/store/products.js index c5a80658fe..5f6a627948 100644 --- a/integration-tests/api/__tests__/store/products.js +++ b/integration-tests/api/__tests__/store/products.js @@ -26,13 +26,8 @@ describe("/store/products", () => { describe("GET /store/products", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) }) afterEach(async () => { @@ -233,13 +228,8 @@ describe("/store/products", () => { describe("list params", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) }) afterEach(async () => { @@ -332,32 +322,27 @@ describe("/store/products", () => { describe("list params", () => { beforeEach(async () => { - try { - await adminSeeder(dbConnection) + await adminSeeder(dbConnection) - await simpleProductFactory( - dbConnection, - { - title: "testprod", - status: "published", - variants: [{ title: "test-variant" }], - }, - 11 - ) + await simpleProductFactory( + dbConnection, + { + title: "testprod", + status: "published", + variants: [{ title: "test-variant" }], + }, + 11 + ) - await simpleProductFactory( - dbConnection, - { - title: "testprod3", - status: "published", - variants: [{ title: "test-variant1" }], - }, - 12 - ) - } catch (err) { - console.log(err) - throw err - } + await simpleProductFactory( + dbConnection, + { + title: "testprod3", + status: "published", + variants: [{ title: "test-variant1" }], + }, + 12 + ) }) afterEach(async () => { @@ -400,13 +385,8 @@ describe("/store/products", () => { describe("/store/products/:id", () => { beforeEach(async () => { - try { - await productSeeder(dbConnection) - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await productSeeder(dbConnection) + await adminSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/store/return-reason.js b/integration-tests/api/__tests__/store/return-reason.js index 36daf1e302..477093d793 100644 --- a/integration-tests/api/__tests__/store/return-reason.js +++ b/integration-tests/api/__tests__/store/return-reason.js @@ -28,18 +28,13 @@ describe("/store/return-reasons", () => { let rrId beforeEach(async () => { - try { - const created = dbConnection.manager.create(ReturnReason, { - value: "wrong_size", - label: "Wrong size", - }) + const created = dbConnection.manager.create(ReturnReason, { + value: "wrong_size", + label: "Wrong size", + }) - const result = await dbConnection.manager.save(created) - rrId = result.id - } catch (err) { - console.log(err) - throw err - } + const result = await dbConnection.manager.save(created) + rrId = result.id }) afterEach(async () => { @@ -73,35 +68,30 @@ describe("/store/return-reasons", () => { let rrId_2 beforeEach(async () => { - try { - const created = dbConnection.manager.create(ReturnReason, { - value: "wrong_size", - label: "Wrong size", - }) + const created = dbConnection.manager.create(ReturnReason, { + value: "wrong_size", + label: "Wrong size", + }) - const result = await dbConnection.manager.save(created) - rrId = result.id + const result = await dbConnection.manager.save(created) + rrId = result.id - const created_child = dbConnection.manager.create(ReturnReason, { - value: "too_big", - label: "Too Big", - parent_return_reason_id: rrId, - }) + const created_child = dbConnection.manager.create(ReturnReason, { + value: "too_big", + label: "Too Big", + parent_return_reason_id: rrId, + }) - const result_child = await dbConnection.manager.save(created_child) - rrId_1 = result_child.id + const result_child = await dbConnection.manager.save(created_child) + rrId_1 = result_child.id - const created_2 = dbConnection.manager.create(ReturnReason, { - value: "too_big_1", - label: "Too Big 1", - }) + const created_2 = dbConnection.manager.create(ReturnReason, { + value: "too_big_1", + label: "Too Big 1", + }) - const result_2 = await dbConnection.manager.save(created_2) - rrId_2 = result_2.id - } catch (err) { - console.log(err) - throw err - } + const result_2 = await dbConnection.manager.save(created_2) + rrId_2 = result_2.id }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/store/sales-channels.js b/integration-tests/api/__tests__/store/sales-channels.js index 3c641f202c..ef4009a35a 100644 --- a/integration-tests/api/__tests__/store/sales-channels.js +++ b/integration-tests/api/__tests__/store/sales-channels.js @@ -6,7 +6,9 @@ const { useDb } = require("../../../helpers/use-db") const adminSeeder = require("../../helpers/admin-seeder") const { simpleSalesChannelFactory, - simpleCartFactory, simpleRegionFactory, simpleProductFactory, + simpleCartFactory, + simpleRegionFactory, + simpleProductFactory, } = require("../../factories") const startServerWithEnvironment = @@ -47,29 +49,25 @@ describe("sales channels", () => { let disabledSalesChannel beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await simpleRegionFactory(dbConnection, { - name: "Test region", - tax_rate: 0, - }) - await simpleSalesChannelFactory(dbConnection, { - name: "Default Sales Channel", - description: "Created by Medusa", - is_default: true - }) - disabledSalesChannel = await simpleSalesChannelFactory(dbConnection, { - name: "disabled cart sales channel", - description: "disabled cart sales channel description", - is_disabled: true, - }) - salesChannel = await simpleSalesChannelFactory(dbConnection, { - name: "cart sales channel", - description: "cart sales channel description", - }) - } catch (err) { - console.log(err) - } + await adminSeeder(dbConnection) + await simpleRegionFactory(dbConnection, { + name: "Test region", + tax_rate: 0, + }) + await simpleSalesChannelFactory(dbConnection, { + name: "Default Sales Channel", + description: "Created by Medusa", + is_default: true, + }) + disabledSalesChannel = await simpleSalesChannelFactory(dbConnection, { + name: "disabled cart sales channel", + description: "disabled cart sales channel description", + is_disabled: true, + }) + salesChannel = await simpleSalesChannelFactory(dbConnection, { + name: "cart sales channel", + description: "cart sales channel description", + }) }) afterEach(async () => { @@ -94,7 +92,11 @@ describe("sales channels", () => { it("returns a cart with the given sales channel", async () => { const api = useApi() - const response = await api.post(`/store/carts`, { sales_channel_id: salesChannel.id }, adminReqConfig) + const response = await api.post( + `/store/carts`, + { sales_channel_id: salesChannel.id }, + adminReqConfig + ) expect(response.data.cart.sales_channel).toBeTruthy() expect(response.data.cart.sales_channel).toEqual( @@ -108,14 +110,18 @@ describe("sales channels", () => { it("throw if the given sales channel is disabled", async () => { const api = useApi() - const err = await api.post( - `/store/carts`, - { sales_channel_id: disabledSalesChannel.id }, - adminReqConfig - ).catch(err => err) + const err = await api + .post( + `/store/carts`, + { sales_channel_id: disabledSalesChannel.id }, + adminReqConfig + ) + .catch((err) => err) expect(err.response.status).toEqual(400) - expect(err.response.data.message).toBe(`Unable to assign the cart to a disabled Sales Channel "disabled cart sales channel"`) + expect(err.response.data.message).toBe( + `Unable to assign the cart to a disabled Sales Channel "disabled cart sales channel"` + ) }) }) @@ -125,81 +131,68 @@ describe("sales channels", () => { let cart beforeEach(async () => { - try { - await adminSeeder(dbConnection) - await simpleRegionFactory(dbConnection, { - name: "Test region", - currency_code: "usd", - tax_rate: 0, - }) + await adminSeeder(dbConnection) + await simpleRegionFactory(dbConnection, { + name: "Test region", + currency_code: "usd", + tax_rate: 0, + }) - salesChannel1 = await simpleSalesChannelFactory(dbConnection, { - name: "salesChannel1", - description: "salesChannel1", - }) - salesChannel2 = await simpleSalesChannelFactory(dbConnection, { - name: "salesChannel2", - description: "salesChannel2", - }) - disabledSalesChannel = await simpleSalesChannelFactory(dbConnection, { - name: "disabled cart sales channel", - description: "disabled cart sales channel description", - is_disabled: true, - }) + salesChannel1 = await simpleSalesChannelFactory(dbConnection, { + name: "salesChannel1", + description: "salesChannel1", + }) + salesChannel2 = await simpleSalesChannelFactory(dbConnection, { + name: "salesChannel2", + description: "salesChannel2", + }) + disabledSalesChannel = await simpleSalesChannelFactory(dbConnection, { + name: "disabled cart sales channel", + description: "disabled cart sales channel description", + is_disabled: true, + }) - product1 = await simpleProductFactory( - dbConnection, + product1 = await simpleProductFactory(dbConnection, { + title: "prod 1", + sales_channels: [salesChannel1], + variants: [ { - title: "prod 1", - sales_channels: [salesChannel1], - variants: [ - { - id: "test-variant", - prices: [ - { - amount: 50, - currency: "usd", - variant_id: "test-variant", - }, - ], - }, - ], - }, - ) - product2 = await simpleProductFactory( - dbConnection, - { - sales_channels: [salesChannel2], - variants: [ - { - id: "test-variant-2", - prices: [ - { - amount: 100, - currency: "usd", - variant_id: "test-variant-2", - }, - ], - }, - ], - }, - ) - - cart = await simpleCartFactory( - dbConnection, - { - sales_channel: salesChannel1, - line_items: [ + id: "test-variant", + prices: [ { + amount: 50, + currency: "usd", variant_id: "test-variant", - unit_price: 50, }, ], }, - ) - } catch (err) { - console.log(err) - } + ], + }) + product2 = await simpleProductFactory(dbConnection, { + sales_channels: [salesChannel2], + variants: [ + { + id: "test-variant-2", + prices: [ + { + amount: 100, + currency: "usd", + variant_id: "test-variant-2", + }, + ], + }, + ], + }) + + cart = await simpleCartFactory(dbConnection, { + sales_channel: salesChannel1, + line_items: [ + { + variant_id: "test-variant", + unit_price: 50, + }, + ], + }) }) afterEach(async () => { @@ -207,52 +200,57 @@ describe("sales channels", () => { await db.teardown() }) - it( - "updates a cart sales channels should remove the items that does not belongs to the new sales channel", - async () => { - const api = useApi() + it("updates a cart sales channels should remove the items that does not belongs to the new sales channel", async () => { + const api = useApi() - let response = await api.get(`/store/carts/${cart.id}`, adminReqConfig) + let response = await api.get(`/store/carts/${cart.id}`, adminReqConfig) - expect(response.data.cart.sales_channel).toBeTruthy() - expect(response.data.cart.sales_channel).toEqual( - expect.objectContaining({ - name: salesChannel1.name, - description: salesChannel1.description, - }) - ) - expect(response.data.cart.items.length).toBe(1) - expect(response.data.cart.items[0].variant.product).toEqual( - expect.objectContaining({ - id: product1.id, - title: product1.title, - }) - ) + expect(response.data.cart.sales_channel).toBeTruthy() + expect(response.data.cart.sales_channel).toEqual( + expect.objectContaining({ + name: salesChannel1.name, + description: salesChannel1.description, + }) + ) + expect(response.data.cart.items.length).toBe(1) + expect(response.data.cart.items[0].variant.product).toEqual( + expect.objectContaining({ + id: product1.id, + title: product1.title, + }) + ) - response = await api.post(`/store/carts/${cart.id}`, { sales_channel_id: salesChannel2.id }, adminReqConfig) + response = await api.post( + `/store/carts/${cart.id}`, + { sales_channel_id: salesChannel2.id }, + adminReqConfig + ) - expect(response.data.cart.sales_channel).toBeTruthy() - expect(response.data.cart.sales_channel).toEqual( - expect.objectContaining({ - name: salesChannel2.name, - description: salesChannel2.description, - }) - ) - expect(response.data.cart.items.length).toBe(0) - } - ) + expect(response.data.cart.sales_channel).toBeTruthy() + expect(response.data.cart.sales_channel).toEqual( + expect.objectContaining({ + name: salesChannel2.name, + description: salesChannel2.description, + }) + ) + expect(response.data.cart.items.length).toBe(0) + }) it("throw if the given sales channel is disabled", async () => { const api = useApi() - const err = await api.post( - `/store/carts/${cart.id}`, - { sales_channel_id: disabledSalesChannel.id }, - adminReqConfig - ).catch(err => err) + const err = await api + .post( + `/store/carts/${cart.id}`, + { sales_channel_id: disabledSalesChannel.id }, + adminReqConfig + ) + .catch((err) => err) expect(err.response.status).toEqual(400) - expect(err.response.data.message).toBe("Unable to assign the cart to a disabled Sales Channel \"disabled cart sales channel\"") + expect(err.response.data.message).toBe( + `Unable to assign the cart to a disabled Sales Channel "disabled cart sales channel"` + ) }) }) @@ -260,18 +258,14 @@ describe("sales channels", () => { let cart beforeEach(async () => { - try { - await adminSeeder(dbConnection) + await adminSeeder(dbConnection) - cart = await simpleCartFactory(dbConnection, { - sales_channel: { - name: "test name", - description: "test description", - }, - }) - } catch (err) { - console.log(err) - } + cart = await simpleCartFactory(dbConnection, { + sales_channel: { + name: "test name", + description: "test description", + }, + }) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/store/swaps.js b/integration-tests/api/__tests__/store/swaps.js index 1065aef2c6..89b8a5d011 100644 --- a/integration-tests/api/__tests__/store/swaps.js +++ b/integration-tests/api/__tests__/store/swaps.js @@ -1,8 +1,5 @@ const path = require("path") -const { - ShippingProfile, - ShippingOption, -} = require("@medusajs/medusa") +const { ShippingProfile, ShippingOption } = require("@medusajs/medusa") const setupServer = require("../../../helpers/setup-server") const { useApi } = require("../../../helpers/use-api") @@ -30,35 +27,30 @@ describe("/store/carts", () => { describe("/store/swaps", () => { beforeEach(async () => { - try { - await orderSeeder(dbConnection) + await orderSeeder(dbConnection) - const manager = dbConnection.manager - await manager.query( - `UPDATE "swap" SET cart_id='test-cart-2' WHERE id = 'test-swap'` - ) - await manager.query( - `UPDATE "payment" SET swap_id=NULL WHERE id = 'test-payment-swap'` - ) + const manager = dbConnection.manager + await manager.query( + `UPDATE "swap" SET cart_id='test-cart-2' WHERE id = 'test-swap'` + ) + await manager.query( + `UPDATE "payment" SET swap_id=NULL WHERE id = 'test-payment-swap'` + ) - const defaultProfile = await manager.findOne(ShippingProfile, { - type: "default", - }) - await manager.insert(ShippingOption, { - id: "return-option", - name: "Test ret", - profile_id: defaultProfile.id, - region_id: "test-region", - provider_id: "test-ful", - data: {}, - price_type: "flat_rate", - amount: 1000, - is_return: true, - }) - } catch (err) { - console.log(err) - throw err - } + const defaultProfile = await manager.findOne(ShippingProfile, { + type: "default", + }) + await manager.insert(ShippingOption, { + id: "return-option", + name: "Test ret", + profile_id: defaultProfile.id, + region_id: "test-region", + provider_id: "test-ful", + data: {}, + price_type: "flat_rate", + amount: 1000, + is_return: true, + }) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/swaps/index.js b/integration-tests/api/__tests__/swaps/index.js index 61d0b055b4..6859a4adc2 100644 --- a/integration-tests/api/__tests__/swaps/index.js +++ b/integration-tests/api/__tests__/swaps/index.js @@ -25,12 +25,8 @@ describe("Swaps", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - dbConnection = await initDb({ cwd }) - medusaProcess = await setupServer({ cwd }) - } catch (error) { - console.log(error) - } + dbConnection = await initDb({ cwd }) + medusaProcess = await setupServer({ cwd }) }) afterAll(async () => { diff --git a/integration-tests/api/__tests__/taxes/admin-tax-rates.js b/integration-tests/api/__tests__/taxes/admin-tax-rates.js index f76932ebe8..49f98e82c7 100644 --- a/integration-tests/api/__tests__/taxes/admin-tax-rates.js +++ b/integration-tests/api/__tests__/taxes/admin-tax-rates.js @@ -26,12 +26,8 @@ describe("/admin/tax-rates", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - dbConnection = await initDb({ cwd }) - medusaProcess = await setupServer({ cwd }) - } catch (error) { - console.log(error) - } + dbConnection = await initDb({ cwd }) + medusaProcess = await setupServer({ cwd }) }) afterAll(async () => { diff --git a/integration-tests/api/__tests__/taxes/automatic-taxes.js b/integration-tests/api/__tests__/taxes/automatic-taxes.js index 6a1bae01f6..bf1427f8ea 100644 --- a/integration-tests/api/__tests__/taxes/automatic-taxes.js +++ b/integration-tests/api/__tests__/taxes/automatic-taxes.js @@ -27,12 +27,8 @@ describe("Automatic Cart Taxes", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - dbConnection = await initDb({ cwd }) - medusaProcess = await setupServer({ cwd }) - } catch (error) { - console.log(error) - } + dbConnection = await initDb({ cwd }) + medusaProcess = await setupServer({ cwd }) }) afterAll(async () => { diff --git a/integration-tests/api/__tests__/taxes/cart.js b/integration-tests/api/__tests__/taxes/cart.js index ea8c3765b7..6619c38f86 100644 --- a/integration-tests/api/__tests__/taxes/cart.js +++ b/integration-tests/api/__tests__/taxes/cart.js @@ -32,12 +32,7 @@ describe("Cart Totals Calculations", () => { }) beforeEach(async () => { - try { - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/taxes/manual-taxes.js b/integration-tests/api/__tests__/taxes/manual-taxes.js index 79c53033a5..dcf33767f9 100644 --- a/integration-tests/api/__tests__/taxes/manual-taxes.js +++ b/integration-tests/api/__tests__/taxes/manual-taxes.js @@ -26,12 +26,8 @@ describe("Manual Cart Taxes", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - dbConnection = await initDb({ cwd }) - medusaProcess = await setupServer({ cwd }) - } catch (error) { - console.log(error) - } + dbConnection = await initDb({ cwd }) + medusaProcess = await setupServer({ cwd }) }) afterAll(async () => { diff --git a/integration-tests/api/__tests__/taxes/orders.js b/integration-tests/api/__tests__/taxes/orders.js index 2299fb20ff..bde86a119b 100644 --- a/integration-tests/api/__tests__/taxes/orders.js +++ b/integration-tests/api/__tests__/taxes/orders.js @@ -25,12 +25,8 @@ describe("Order Taxes", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - dbConnection = await initDb({ cwd }) - medusaProcess = await setupServer({ cwd }) - } catch (error) { - console.log(error) - } + dbConnection = await initDb({ cwd }) + medusaProcess = await setupServer({ cwd }) }) afterAll(async () => { diff --git a/integration-tests/api/__tests__/taxes/shipping-options.js b/integration-tests/api/__tests__/taxes/shipping-options.js index 7f91216db8..ea6d1e10b9 100644 --- a/integration-tests/api/__tests__/taxes/shipping-options.js +++ b/integration-tests/api/__tests__/taxes/shipping-options.js @@ -32,12 +32,7 @@ describe("Shipping Options Totals Calculations", () => { }) beforeEach(async () => { - try { - await adminSeeder(dbConnection) - } catch (err) { - console.log(err) - throw err - } + await adminSeeder(dbConnection) }) afterEach(async () => { diff --git a/integration-tests/api/__tests__/totals/orders.js b/integration-tests/api/__tests__/totals/orders.js index 2cb3d2f2fe..52c715daae 100644 --- a/integration-tests/api/__tests__/totals/orders.js +++ b/integration-tests/api/__tests__/totals/orders.js @@ -25,12 +25,8 @@ describe("Order Totals", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - dbConnection = await initDb({ cwd }) - medusaProcess = await setupServer({ cwd }) - } catch (error) { - console.log(error) - } + dbConnection = await initDb({ cwd }) + medusaProcess = await setupServer({ cwd }) }) afterAll(async () => { diff --git a/integration-tests/api/package.json b/integration-tests/api/package.json index e63e33a033..3427a8623d 100644 --- a/integration-tests/api/package.json +++ b/integration-tests/api/package.json @@ -4,7 +4,7 @@ "main": "index.js", "license": "MIT", "scripts": { - "test": "jest --silent=false", + "test": "jest --silent=false --runInBand --bail", "build": "babel src -d dist --extensions \".ts,.js\"" }, "dependencies": { diff --git a/integration-tests/helpers/bootstrap-app.js b/integration-tests/helpers/bootstrap-app.js index 52ebc998cb..0dc1c221e2 100644 --- a/integration-tests/helpers/bootstrap-app.js +++ b/integration-tests/helpers/bootstrap-app.js @@ -5,30 +5,26 @@ const importFrom = require("import-from") module.exports = { bootstrapApp: async ({ cwd } = {}) => { - try { - const app = express() + const app = express() - const loaders = importFrom( - cwd || process.cwd(), - "@medusajs/medusa/dist/loaders" - ).default + const loaders = importFrom( + cwd || process.cwd(), + "@medusajs/medusa/dist/loaders" + ).default - const { container, dbConnection } = await loaders({ - directory: path.resolve(cwd || process.cwd()), - expressApp: app, - isTest: false, - }) + const { container, dbConnection } = await loaders({ + directory: path.resolve(cwd || process.cwd()), + expressApp: app, + isTest: false, + }) - const PORT = await getPort() + const PORT = await getPort() - return { - container, - db: dbConnection, - app, - port: PORT, - } - } catch (e) { - console.log(e) + return { + container, + db: dbConnection, + app, + port: PORT, } }, } diff --git a/integration-tests/helpers/use-template-db.js b/integration-tests/helpers/use-template-db.js index 5af2fe9797..fa6333381d 100644 --- a/integration-tests/helpers/use-template-db.js +++ b/integration-tests/helpers/use-template-db.js @@ -24,65 +24,60 @@ class DatabaseFactory { } async createTemplateDb_({ cwd }) { - try { - // const cwd = path.resolve(path.join(__dirname, "..")) - const connection = await this.getMasterConnection() - const migrationDir = path.resolve( - path.join( - cwd, - `node_modules`, - `@medusajs`, - `medusa`, - `dist`, - `migrations`, - `*.js` - ) - ) - - const { getEnabledMigrations } = require(path.join( + // const cwd = path.resolve(path.join(__dirname, "..")) + const connection = await this.getMasterConnection() + const migrationDir = path.resolve( + path.join( cwd, `node_modules`, `@medusajs`, `medusa`, `dist`, - `commands`, - `utils`, - `get-migrations` - )) - - // filter migrations to only include those that dont have feature flags - const enabledMigrations = await getEnabledMigrations( - [migrationDir], - (flag) => false + `migrations`, + `*.js` ) + ) - await dropDatabase( - { - databaseName: this.templateDbName, - errorIfNonExist: false, - }, - pgGodCredentials - ) - await createDatabase( - { databaseName: this.templateDbName }, - pgGodCredentials - ) + const { getEnabledMigrations } = require(path.join( + cwd, + `node_modules`, + `@medusajs`, + `medusa`, + `dist`, + `commands`, + `utils`, + `get-migrations` + )) - const templateDbConnection = await createConnection({ - type: "postgres", - name: "templateConnection", - url: `${DB_URL}/${this.templateDbName}`, - migrations: enabledMigrations, - }) + // filter migrations to only include those that dont have feature flags + const enabledMigrations = await getEnabledMigrations( + [migrationDir], + (flag) => false + ) - await templateDbConnection.runMigrations() - await templateDbConnection.close() + await dropDatabase( + { + databaseName: this.templateDbName, + errorIfNonExist: false, + }, + pgGodCredentials + ) + await createDatabase( + { databaseName: this.templateDbName }, + pgGodCredentials + ) - return connection - } catch (err) { - console.log("error in createTemplateDb_") - console.log(err) - } + const templateDbConnection = await createConnection({ + type: "postgres", + name: "templateConnection", + url: `${DB_URL}/${this.templateDbName}`, + migrations: enabledMigrations, + }) + + await templateDbConnection.runMigrations() + await templateDbConnection.close() + + return connection } async getMasterConnection() { diff --git a/integration-tests/plugins/__tests__/medusa-plugin-sendgrid/index.js b/integration-tests/plugins/__tests__/medusa-plugin-sendgrid/index.js index d94e82fe3d..7bd53a1014 100644 --- a/integration-tests/plugins/__tests__/medusa-plugin-sendgrid/index.js +++ b/integration-tests/plugins/__tests__/medusa-plugin-sendgrid/index.js @@ -27,19 +27,14 @@ describe("medusa-plugin-sendgrid", () => { beforeAll(async () => { const cwd = path.resolve(path.join(__dirname, "..", "..")) - try { - dbConnection = await initDb({ cwd }) - const { container, app, port } = await bootstrapApp({ cwd }) - appContainer = container + dbConnection = await initDb({ cwd }) + const { container, app, port } = await bootstrapApp({ cwd }) + appContainer = container - setPort(port) - express = app.listen(port, (err) => { - process.send(port) - }) - } catch (error) { - console.log(error) - throw error - } + setPort(port) + express = app.listen(port, (err) => { + process.send(port) + }) }) afterAll(async () => { diff --git a/package.json b/package.json index df3a6070fe..557c05049d 100644 --- a/package.json +++ b/package.json @@ -64,10 +64,10 @@ "jest": "jest", "test": "turbo run test", "prettier": "prettier", - "test:integration": "NODE_ENV=test jest --runInBand --config=integration-tests/jest.config.js", - "test:integration:api": "NODE_ENV=test jest --runInBand --config=integration-tests/jest.config.js --projects=integration-tests/api", - "test:integration:plugins": "NODE_ENV=test jest --runInBand --config=integration-tests/jest.config.js --projects=integration-tests/plugins", - "test:fixtures": "NODE_ENV=test jest --config=docs-util/jest.config.js --runInBand", + "test:integration": "NODE_ENV=test jest --runInBand --bail --config=integration-tests/jest.config.js", + "test:integration:api": "NODE_ENV=test jest --runInBand --bail --config=integration-tests/jest.config.js --projects=integration-tests/api", + "test:integration:plugins": "NODE_ENV=test jest --runInBand --bail --config=integration-tests/jest.config.js --projects=integration-tests/plugins", + "test:fixtures": "NODE_ENV=test jest --config=docs-util/jest.config.js --runInBand --bail", "openapi:generate": "node ./scripts/build-openapi.js", "generate:services": "typedoc --options typedoc.services.js", "generate:js-client": "typedoc --options typedoc.js-client.js",