chore(integration): throw errors on catch blocks (#2091)

Why:
Suppressing errors and not failing the execution will lead to misleading errors of the following tests.

Fixes CORE-461
This commit is contained in:
Carlos R. L. Rodrigues authored and GitHub committed 2022-08-25 06:36:24 +00:00
1 parent 5a964e6439
commit ffd6234356
50 files changed
+60 -641

No files matched your search

+1 -1
View File
@@ -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
@@ -18,11 +18,7 @@ describe("/admin/auth", () => {
dbConnection = await initDb({ cwd })
medusaProcess = await setupServer({ cwd })
try {
await adminSeeder(dbConnection)
} catch (e) {
throw e
}
})
afterAll(async () => {
@@ -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
}
})
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
}
})
afterEach(async () => {
@@ -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
}
})
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
}
})
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
}
})
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
}
})
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
}
})
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
}
})
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
}
})
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
}
})
afterEach(async () => {
@@ -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
}
})
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
}
})
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
}
})
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
}
})
afterEach(async () => {
@@ -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
}
})
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)
}
const prod = await simpleProductFactory(dbConnection, {
type: "pants",
@@ -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
}
})
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
}
})
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
}
})
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
}
})
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
}
})
afterEach(async () => {
@@ -28,7 +28,7 @@ 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",
@@ -50,10 +50,6 @@ describe("/admin/gift-cards", () => {
balance: 200000,
region_id: "test-region",
})
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -136,7 +132,7 @@ 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",
@@ -151,10 +147,6 @@ describe("/admin/gift-cards", () => {
balance: 20000,
region_id: "region",
})
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
+4 -20
View File
@@ -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)
}
})
afterEach(async () => {
@@ -73,11 +70,7 @@ describe("/admin/notes", () => {
describe("POST /admin/notes", () => {
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
}
})
afterEach(async () => {
@@ -121,7 +114,7 @@ describe("/admin/notes", () => {
describe("GET /admin/notes", () => {
beforeEach(async () => {
const manager = dbConnection.manager
try {
await adminSeeder(dbConnection)
await manager.insert(Note, { ...note, id: "note1" })
@@ -131,9 +124,6 @@ describe("/admin/notes", () => {
id: "note3",
resource_id: "resource2",
})
} catch (err) {
console.log(err)
}
})
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)
}
})
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)
}
})
afterEach(async () => {
+4 -46
View File
@@ -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
}
})
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
}
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
}
})
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
}
})
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
}
})
afterEach(async () => {
@@ -1272,7 +1247,6 @@ describe("/admin/orders", () => {
describe("POST /admin/orders/:id/return", () => {
let rrId
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
await orderSeeder(dbConnection)
@@ -1283,10 +1257,6 @@ describe("/admin/orders", () => {
const result = await dbConnection.manager.save(created)
rrId = result.id
} catch (err) {
console.log(err)
throw err
}
})
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
}
})
afterEach(async () => {
@@ -1521,7 +1486,8 @@ describe("/admin/orders", () => {
expect(response.status).toEqual(200)
expect(response.data.count).toEqual(2)
expect(response.data.orders).toEqual(expect.arrayContaining([
expect(response.data.orders).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: "test-order",
shipping_address: expect.objectContaining({ first_name: "lebron" }),
@@ -1530,7 +1496,8 @@ describe("/admin/orders", () => {
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
}
})
afterEach(async () => {
@@ -2137,7 +2099,6 @@ describe("/admin/orders", () => {
})
it("Only allows canceling swap after canceling fulfillments", async () => {
try {
const swap_id = "swap-w-f"
const swap = await callGet({
@@ -2161,9 +2122,6 @@ describe("/admin/orders", () => {
})
await expectCancelToReturn({ code: 200 })
} catch (e) {
console.log(e)
}
})
it("Only allows canceling swap after canceling return", async () => {
@@ -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
}
})
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
}
})
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
}
})
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
}
})
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
}
})
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
}
})
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
}
})
afterEach(async () => {
@@ -1102,7 +1067,6 @@ describe("/admin/price-lists", () => {
describe("GET /admin/price-lists/:id/products", () => {
let tag
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
await simpleProductFactory(
@@ -1151,10 +1115,6 @@ describe("/admin/price-lists", () => {
{ variant_id: "test-variant-4", currency_code: "usd", amount: 200 },
],
})
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -1278,7 +1238,6 @@ describe("/admin/price-lists", () => {
}
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
product1 = await simpleProductFactory(
@@ -1329,10 +1288,6 @@ describe("/admin/price-lists", () => {
})),
],
})
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -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
}
})
afterEach(async () => {
@@ -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
}
})
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])
})
})
})
@@ -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
}
})
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
}
})
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
}
})
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
}
})
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
}
})
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
}
})
afterEach(async () => {
@@ -27,7 +27,6 @@ describe("/admin/regions", () => {
describe("Remove region from country on delete", () => {
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
const manager = dbConnection.manager
await manager.insert(Region, {
@@ -40,10 +39,6 @@ describe("/admin/regions", () => {
await manager.query(
`UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'`
)
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -203,7 +198,6 @@ describe("/admin/regions", () => {
describe("DELETE /admin/regions/:id", () => {
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
const manager = dbConnection.manager
await manager.insert(Region, {
@@ -216,10 +210,6 @@ describe("/admin/regions", () => {
await manager.query(
`UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'`
)
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -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
}
})
afterEach(async () => {
@@ -31,7 +31,6 @@ describe("/admin/returns", () => {
let rrId
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
await orderSeeder(dbConnection)
@@ -41,10 +40,6 @@ describe("/admin/returns", () => {
})
const resultRR = await dbConnection.manager.save(created)
rrId = resultRR.id
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -233,7 +228,7 @@ describe("/admin/returns", () => {
return_shipping: {
option_id: "test-option",
price: 0,
}
},
},
{
headers: {
@@ -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)
}
})
afterEach(async () => {
@@ -92,7 +88,6 @@ describe("sales channels", () => {
let salesChannel2
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
salesChannel1 = await simpleSalesChannelFactory(dbConnection, {
name: "test name",
@@ -102,9 +97,6 @@ describe("sales channels", () => {
name: "test name 2",
description: "test description 2",
})
} catch (e) {
console.error(e)
}
})
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)
}
})
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)
}
})
afterEach(async () => {
@@ -324,7 +308,6 @@ describe("sales channels", () => {
let salesChannel
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
salesChannel = await simpleSalesChannelFactory(dbConnection, {
name: "test name",
@@ -336,9 +319,6 @@ describe("sales channels", () => {
id: "test-channel",
is_default: true,
})
} catch (e) {
console.error(e)
}
})
afterEach(async () => {
@@ -454,7 +434,6 @@ describe("sales channels", () => {
describe("GET /admin/orders/:id", () => {
let order
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
order = await simpleOrderFactory(dbConnection, {
@@ -463,9 +442,6 @@ describe("sales channels", () => {
description: "test description",
},
})
} catch (err) {
console.log(err)
}
})
afterEach(async () => {
@@ -495,7 +471,6 @@ describe("sales channels", () => {
describe("GET /admin/orders?expand=sales_channels", () => {
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
await simpleOrderFactory(dbConnection, {
@@ -504,9 +479,6 @@ describe("sales channels", () => {
description: "test description",
},
})
} catch (err) {
console.log(err)
}
})
afterEach(async () => {
@@ -537,7 +509,6 @@ describe("sales channels", () => {
describe("GET /admin/product/:id", () => {
let product
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
product = await simpleProductFactory(dbConnection, {
@@ -552,9 +523,6 @@ describe("sales channels", () => {
},
],
})
} catch (err) {
console.log(err)
}
})
afterEach(async () => {
@@ -589,7 +557,6 @@ describe("sales channels", () => {
describe("GET /admin/products?expand[]=sales_channels", () => {
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
await simpleProductFactory(dbConnection, {
@@ -604,9 +571,6 @@ describe("sales channels", () => {
},
],
})
} catch (err) {
console.log(err)
}
})
afterEach(async () => {
@@ -645,7 +609,6 @@ describe("sales channels", () => {
let product
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
product = await simpleProductFactory(dbConnection, {
id: "product_1",
@@ -656,9 +619,6 @@ describe("sales channels", () => {
description: "test description",
products: [product],
})
} catch (e) {
console.error(e)
}
})
afterEach(async () => {
@@ -730,7 +690,6 @@ describe("sales channels", () => {
let product
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
salesChannel = await simpleSalesChannelFactory(dbConnection, {
name: "test name",
@@ -740,9 +699,6 @@ describe("sales channels", () => {
id: "product_1",
title: "test title",
})
} catch (e) {
console.error(e)
}
})
afterEach(async () => {
@@ -798,7 +754,6 @@ describe("sales channels", () => {
let order
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
order = await simpleOrderFactory(dbConnection, {
sales_channel: {
@@ -807,10 +762,6 @@ describe("sales channels", () => {
},
})
await orderSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -850,7 +801,6 @@ describe("sales channels", () => {
let salesChannel
beforeEach(async () => {
try {
await productSeeder(dbConnection)
await adminSeeder(dbConnection)
const product = await simpleProductFactory(dbConnection, productData)
@@ -859,10 +809,6 @@ describe("sales channels", () => {
description: "test description",
products: [product],
})
} catch (err) {
console.log(err)
throw err
}
})
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
}
})
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
}
})
afterEach(async () => {
@@ -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
}
})
afterEach(async () => {
@@ -254,7 +249,6 @@ describe("/admin/shipping-options", () => {
let payload
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
await shippingOptionSeeder(dbConnection)
@@ -285,10 +279,6 @@ describe("/admin/shipping-options", () => {
data: {},
profile_id: defaultProfile.id,
}
} catch (err) {
console.error(err)
throw err
}
})
afterEach(async () => {
@@ -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
}
})
afterEach(async () => {
@@ -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
}
})
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
}
})
afterEach(async () => {
@@ -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
}
})
afterEach(async () => {
@@ -18,7 +18,6 @@ const adminReqConfig = {
}
const setupJobDb = async (dbConnection) => {
try {
await adminSeeder(dbConnection)
await userSeeder(dbConnection)
@@ -50,10 +49,6 @@ const setupJobDb = async (dbConnection) => {
completed_at: "2022-06-27T22:00:00.000Z",
created_by: "admin_user",
})
} catch (err) {
console.log(err)
throw err
}
}
describe("/admin/batch-jobs", () => {
@@ -251,7 +246,6 @@ describe("/admin/batch-jobs", () => {
describe("POST /admin/batch-jobs/:id/cancel", () => {
beforeEach(async () => {
try {
await setupJobDb(dbConnection)
await simpleBatchJobFactory(dbConnection, {
id: "job_complete",
@@ -259,10 +253,6 @@ describe("/admin/batch-jobs", () => {
created_by: "admin_user",
completed_at: new Date(),
})
} catch (e) {
console.log(e)
throw e
}
})
afterEach(async () => {
@@ -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
}
})
afterEach(async () => {
@@ -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
}
})
afterEach(async () => {
@@ -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)
}
})
afterAll(async () => {
@@ -20,7 +20,6 @@ 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 },
@@ -28,9 +27,6 @@ describe("Line Item - Sales Channel", () => {
})
dbConnection = connection
medusaProcess = process
} catch (error) {
console.log(error)
}
})
afterAll(async () => {
@@ -40,7 +36,6 @@ describe("Line Item - Sales Channel", () => {
})
beforeEach(async () => {
try {
await simpleProductFactory(dbConnection, {
id: "test-product-in-sales-channel",
title: "test product belonging to a channel",
@@ -83,10 +78,6 @@ describe("Line Item - Sales Channel", () => {
id: "main-sales-channel",
},
})
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -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)
}
})
afterAll(async () => {
@@ -41,7 +37,6 @@ describe("Line Item Adjustments", () => {
discount,
lineItemId = "line-test"
beforeEach(async () => {
try {
await cartSeeder(dbConnection)
discount = await simpleDiscountFactory(dbConnection, {
code: "MEDUSATEST",
@@ -91,10 +86,6 @@ describe("Line Item Adjustments", () => {
},
100
)
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -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
}
})
afterEach(async () => {
@@ -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)
}
})
afterAll(async () => {
+1 -41
View File
@@ -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)
}
})
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
}
})
afterEach(async () => {
@@ -495,12 +486,7 @@ describe("/store/carts", () => {
let discountCart
let discount
beforeEach(async () => {
try {
discount = await simpleDiscountFactory(
dbConnection,
discountData,
100
)
discount = await simpleDiscountFactory(dbConnection, discountData, 100)
discountCart = await simpleCartFactory(
dbConnection,
{
@@ -543,9 +529,6 @@ describe("/store/carts", () => {
.relation(Cart, "discounts")
.of(discountCart)
.add(discount)
} catch (err) {
console.log(err)
}
})
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
}
})
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
}
})
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)
}
// check to see if payment is authorized and cart is completed
const res = await api.get(`/store/carts/swap-cart`)
@@ -1753,7 +1722,6 @@ describe("/store/carts", () => {
describe("POST /store/carts/:id/shipping-methods", () => {
beforeEach(async () => {
try {
await cartSeeder(dbConnection)
const manager = dbConnection.manager
@@ -1779,9 +1747,6 @@ describe("/store/carts", () => {
shipping_option_id: "test-option",
price: 5,
})
} catch (err) {
console.log(err)
}
})
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
}
})
afterEach(async () => {
@@ -25,12 +25,7 @@ describe("/store/collections", () => {
describe("/store/collections/:id", () => {
beforeEach(async () => {
try {
await productSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
})
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
}
})
afterEach(async () => {
@@ -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
}
})
afterEach(async () => {
@@ -26,7 +26,6 @@ describe("/store/variants", () => {
describe("GET /store/variants", () => {
beforeEach(async () => {
try {
await productSeeder(dbConnection)
await simpleProductFactory(
@@ -46,10 +45,6 @@ describe("/store/variants", () => {
},
100
)
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -169,7 +164,6 @@ describe("/store/variants", () => {
describe("GET /store/variants advanced pricing", () => {
beforeEach(async () => {
try {
await storeProductSeeder(dbConnection)
await simpleProductFactory(
@@ -189,10 +183,6 @@ describe("/store/variants", () => {
},
100
)
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -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
}
})
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
}
})
afterEach(async () => {
@@ -332,7 +322,6 @@ describe("/store/products", () => {
describe("list params", () => {
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
await simpleProductFactory(
@@ -354,10 +343,6 @@ describe("/store/products", () => {
},
12
)
} catch (err) {
console.log(err)
throw err
}
})
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
}
})
afterEach(async () => {
@@ -28,7 +28,6 @@ describe("/store/return-reasons", () => {
let rrId
beforeEach(async () => {
try {
const created = dbConnection.manager.create(ReturnReason, {
value: "wrong_size",
label: "Wrong size",
@@ -36,10 +35,6 @@ describe("/store/return-reasons", () => {
const result = await dbConnection.manager.save(created)
rrId = result.id
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -73,7 +68,6 @@ describe("/store/return-reasons", () => {
let rrId_2
beforeEach(async () => {
try {
const created = dbConnection.manager.create(ReturnReason, {
value: "wrong_size",
label: "Wrong size",
@@ -98,10 +92,6 @@ describe("/store/return-reasons", () => {
const result_2 = await dbConnection.manager.save(created_2)
rrId_2 = result_2.id
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -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,7 +49,6 @@ describe("sales channels", () => {
let disabledSalesChannel
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
await simpleRegionFactory(dbConnection, {
name: "Test region",
@@ -56,7 +57,7 @@ describe("sales channels", () => {
await simpleSalesChannelFactory(dbConnection, {
name: "Default Sales Channel",
description: "Created by Medusa",
is_default: true
is_default: true,
})
disabledSalesChannel = await simpleSalesChannelFactory(dbConnection, {
name: "disabled cart sales channel",
@@ -67,9 +68,6 @@ describe("sales channels", () => {
name: "cart sales channel",
description: "cart sales channel description",
})
} catch (err) {
console.log(err)
}
})
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(
const err = await api
.post(
`/store/carts`,
{ sales_channel_id: disabledSalesChannel.id },
adminReqConfig
).catch(err => err)
)
.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,7 +131,6 @@ describe("sales channels", () => {
let cart
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
await simpleRegionFactory(dbConnection, {
name: "Test region",
@@ -147,9 +152,7 @@ describe("sales channels", () => {
is_disabled: true,
})
product1 = await simpleProductFactory(
dbConnection,
{
product1 = await simpleProductFactory(dbConnection, {
title: "prod 1",
sales_channels: [salesChannel1],
variants: [
@@ -164,11 +167,8 @@ describe("sales channels", () => {
],
},
],
},
)
product2 = await simpleProductFactory(
dbConnection,
{
})
product2 = await simpleProductFactory(dbConnection, {
sales_channels: [salesChannel2],
variants: [
{
@@ -182,12 +182,9 @@ describe("sales channels", () => {
],
},
],
},
)
})
cart = await simpleCartFactory(
dbConnection,
{
cart = await simpleCartFactory(dbConnection, {
sales_channel: salesChannel1,
line_items: [
{
@@ -195,11 +192,7 @@ describe("sales channels", () => {
unit_price: 50,
},
],
},
)
} catch (err) {
console.log(err)
}
})
})
afterEach(async () => {
@@ -207,9 +200,7 @@ 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 () => {
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)
@@ -229,7 +220,11 @@ describe("sales channels", () => {
})
)
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(
@@ -239,20 +234,23 @@ describe("sales channels", () => {
})
)
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(
const err = await api
.post(
`/store/carts/${cart.id}`,
{ sales_channel_id: disabledSalesChannel.id },
adminReqConfig
).catch(err => err)
)
.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,7 +258,6 @@ describe("sales channels", () => {
let cart
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
cart = await simpleCartFactory(dbConnection, {
@@ -269,9 +266,6 @@ describe("sales channels", () => {
description: "test description",
},
})
} catch (err) {
console.log(err)
}
})
afterEach(async () => {
@@ -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,7 +27,6 @@ describe("/store/carts", () => {
describe("/store/swaps", () => {
beforeEach(async () => {
try {
await orderSeeder(dbConnection)
const manager = dbConnection.manager
@@ -55,10 +51,6 @@ describe("/store/carts", () => {
amount: 1000,
is_return: true,
})
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -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)
}
})
afterAll(async () => {
@@ -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)
}
})
afterAll(async () => {
@@ -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)
}
})
afterAll(async () => {
@@ -32,12 +32,7 @@ describe("Cart Totals Calculations", () => {
})
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -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)
}
})
afterAll(async () => {
@@ -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)
}
})
afterAll(async () => {
@@ -32,12 +32,7 @@ describe("Shipping Options Totals Calculations", () => {
})
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
@@ -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)
}
})
afterAll(async () => {
+1 -1
View File
@@ -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": {
-4
View File
@@ -5,7 +5,6 @@ const importFrom = require("import-from")
module.exports = {
bootstrapApp: async ({ cwd } = {}) => {
try {
const app = express()
const loaders = importFrom(
@@ -27,8 +26,5 @@ module.exports = {
app,
port: PORT,
}
} catch (e) {
console.log(e)
}
},
}
@@ -24,7 +24,6 @@ class DatabaseFactory {
}
async createTemplateDb_({ cwd }) {
try {
// const cwd = path.resolve(path.join(__dirname, ".."))
const connection = await this.getMasterConnection()
const migrationDir = path.resolve(
@@ -79,10 +78,6 @@ class DatabaseFactory {
await templateDbConnection.close()
return connection
} catch (err) {
console.log("error in createTemplateDb_")
console.log(err)
}
}
async getMasterConnection() {
@@ -27,7 +27,6 @@ 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
@@ -36,10 +35,6 @@ describe("medusa-plugin-sendgrid", () => {
express = app.listen(port, (err) => {
process.send(port)
})
} catch (error) {
console.log(error)
throw error
}
})
afterAll(async () => {
+4 -4
View File
@@ -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",