Creates test request helper for API endpoints
Separates common utils into the medusa-core-utils package. Sets up a testing environment where mocked models/services/etc. can be placed in __mocks__ folder within its corresponding directory. The mocks will automatically be registered in a awilix container only used for testing.
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* @typedef MedusaErrorType
|
||||
*
|
||||
*/
|
||||
export const MedusaErrorTypes = {
|
||||
/** Errors stemming from the database */
|
||||
DB_ERROR: "database_error",
|
||||
INVALID_ARGUMENT: "invalid_argument",
|
||||
INVALID_DATA: "invalid_data",
|
||||
NOT_FOUND: "not_found"
|
||||
}
|
||||
|
||||
/**
|
||||
* Standardized error to be used across Medusa project.
|
||||
* @extends Error
|
||||
*/
|
||||
class MedusaError extends Error {
|
||||
/**
|
||||
* Creates a standardized error to be used across Medusa project.
|
||||
* @param type {MedusaErrorType} - the type of error.
|
||||
* @param params {Array} - Error params.
|
||||
*/
|
||||
constructor(name, message, ...params) {
|
||||
super(...params)
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, MedusaError)
|
||||
}
|
||||
|
||||
this.name = name
|
||||
this.message = message
|
||||
this.date = new Date()
|
||||
}
|
||||
}
|
||||
|
||||
export default MedusaError
|
||||
@@ -1,4 +0,0 @@
|
||||
import Joi from "@hapi/joi"
|
||||
Joi.objectId = require("joi-objectid")(Joi)
|
||||
|
||||
export default Joi
|
||||
Reference in New Issue
Block a user