kysely-mapper
Version:
Flexible Kysely-based utility for mapping between tables and objects
39 lines • 1.54 kB
JavaScript
/**
* Generic testing utilities
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
/**
* Retrieve an error for examination. Modified from
* https://stackoverflow.com/a/49512933/650894
*
* @param call Function that may throw an error; can be async
* @returns The thrown error if one was thrown, otherwise returns
* the error NoErrorThrownError
*/
export function getError(call) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield call(); // need not be async
return null;
}
catch (err) {
return err;
}
});
}
/**
* Embeds code that will never run within a callback. Useful for
* testing expected type errors.
* @param description Description of the code that will never run
* @param callback Callback that will never run
*/
export function ignore(_description, _) { }
//# sourceMappingURL=test-utils.js.map