摩卡条件测试 - 如果其他总是通过

Mocha conditional testing - If else always passes

我正在尝试对我的一个元素进行条件测试,但 mocha 完全跳过 "if else" 语句,只显示 "it("")"[=12= 的输出]

我是这样做的:

    it('if test case', async function () {

        var cardProcZero = await driver.hasElementByAccessibilityId("card_proc_0"); // looks up the element

        let visivel = expect(cardProcZero).to.be.ok; // expects it to exist 
        let naoVisivel = expect(cardProcZero).to.not.be.ok; // expects it not to exist

        if (cardProcZero == naoVisivel) { // if it's not visible, it creates the element
            let adicionarProc = await driver.waitForElementByAccessibilityId("button_addProcedimento"); // adds the element
            await adicionarProc.click();
            return false;

        } else if (cardProcZero == visivel) { // if it is visible, it clicks on it
            await cardProcZero.click(); // clicks on existing element
            return true;
        }
    });

在终端中,mocha 输出这个,就在我最后一个测试用例之后:

✓ if test case (527ms)

它甚至不尝试做其他现有的 "it's"。它只是跳过它。

我到底做错了什么?

尝试在没有 chai.js 期望的情况下进行,并且有效。

这是我的做法,如果有人有同样的问题:

it('if test case', async function () {
    var cardProcZeroVerify = await driver.hasElementByAccessibilityId("card_proc_0"); 

    if (cardProcZeroVerify === false || undefined || null) { 
        console.warn('Adicionando novo procedimento');
        let adicionarProc = await driver.waitForElementByAccessibilityId("button_addProcedimento"); 
        await adicionarProc.click();
    }

    else {
        console.warn('Abrindo um procedimento já existente');
        let cardProcZero = await driver.waitForElementByAccessibilityId("card_proc_0"); 
        await cardProcZero.click();
    }
});