fix: support Ava "macros" in ses-ava
MODIFY
packages/ses-ava/src/ses-ava-test.js
packages/ses-ava/src/ses-ava-test.js
@@ -66,13 +66,16 @@ const testerMethodsWhitelist = [
*/
const wrapTester = (testerFunc, logger = defaultLogger) => {
/** @type {TesterFunc} */
- const testerWrapper = (title, implFunc) => {
+ const testerWrapper = (title, implFunc, ...otherArgs) => {
/** @type {ImplFunc} */
const testFuncWrapper = t => {
harden(t);
- return logErrorFirst(implFunc, [t], 'ava test', logger);
+ return logErrorFirst(implFunc, [t, ...otherArgs], 'ava test', logger);
};
- return testerFunc(title, testFuncWrapper);
+ if (implFunc && implFunc.title) {
+ testFuncWrapper.title = implFunc.title;
+ }
+ return testerFunc(title, testFuncWrapper, ...otherArgs);
};
return testerWrapper;
};
@@ -112,8 +115,8 @@ const wrapTest = (avaTest, logger = defaultLogger) => {
for (const methodName of testerMethodsWhitelist) {
if (methodName in avaTest) {
/** @type {TesterFunc} */
- const testerMethod = (title, implFunc) =>
- avaTest[methodName](title, implFunc);
+ const testerMethod = (title, implFunc, ...otherArgs) =>
+ avaTest[methodName](title, implFunc, ...otherArgs);
testerWrapper[methodName] = wrapTester(testerMethod);
}
}

MODIFY
packages/ses-ava/src/types.js
packages/ses-ava/src/types.js
*/
/**
- * @callback ImplFunc
+ * @callback BaseImplFunc
* This is the function that invariably starts `t => {`.
* Ava's types call this `Implementation`, but that's just too confusing.
*
* @param {Assertions} t
* @returns {unknown}
*
+ * @typedef {BaseImplFunc | Object} ImplFunc
+ * @property {(...unknown) => string} [title]
+ *
* @callback TesterFunc
* @param {string} title
* @param {ImplFunc} implFunc

fix: support Ava "macros" in ses-ava (#641)