From b1da5059f1c6799438ae6eff76c035c50b6b2fac Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Tue, 09 Aug 2022 16:46:03 +0000 Subject: [PATCH] fix: warn about skipped tests --- --- a/tests/src/util/helpers.ts +++ b/tests/src/util/helpers.ts @@ -47,6 +47,7 @@ ReFungible = 'refungible', Fungible = 'fungible', NFT = 'nonfungible', + Scheduler = 'scheduler', } export async function isUnique(): Promise { @@ -72,12 +73,28 @@ return modulesNames; } -export function requirePallets(mocha: Context, api: ApiPromise, requiredPallets: string[]) { - const pallets = getModuleNames(api); +export async function missingRequiredPallets(requiredPallets: string[]): Promise { + return await usingApi(async api => { + const pallets = getModuleNames(api); - const isAllPalletsPresent = requiredPallets.every(p => pallets.includes(p)); + return requiredPallets.filter(p => !pallets.includes(p)); + }); +} - if (!isAllPalletsPresent) { +export async function checkPalletsPresence(requiredPallets: string[]): Promise { + return (await missingRequiredPallets(requiredPallets)).length == 0; +} + +export async function requirePallets(mocha: Context, requiredPallets: string[]) { + const missingPallets = await missingRequiredPallets(requiredPallets); + + if (missingPallets.length > 0) { + const skippingTestMsg = `\tSkipping test "${mocha.test?.title}".`; + const missingPalletsMsg = `\tThe following pallets are missing:\n\t- ${missingPallets.join('\n\t- ')}`; + const skipMsg = `${skippingTestMsg}\n${missingPalletsMsg}`; + + console.log('\x1b[38:5:208m%s\x1b[0m', skipMsg); + mocha.skip(); } } -- gitstuff