How to use the testcafe.t.expect function in testcafe

To help you get started, we’ve selected a few testcafe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / testcafe_v0.x.x / test_testcafe_v0.x.x_clientfunction.js View on Github external
test('ClientFunction call with complex return types', async() => {
    const fn = ClientFunction(() => {
        return [/\S+/ig, new Error('Hey!'), void 0, NaN];
    });

    const res = await fn();

    await t.expect(res[0].source).eql('\\S+');
    await t.expect(res[1].message).eql('Hey!');
    await t.expect(res[2]).eql(void 0);
    await t.expect(Number.isNaN(res[3])).ok();
});
github flow-typed / flow-typed / definitions / npm / testcafe_v0.x.x / test_testcafe_v0.x.x_clientfunction.js View on Github external
test('Call with arguments', async() => {
    const getElementText = ClientFunction((className, idx) => {
        return document.querySelectorAll('.' + className)[idx].textContent;
    });

    const answer = await getElementText('answer', 1);

    await t.expect(answer.trim()).eql('42');
});
github flow-typed / flow-typed / definitions / npm / testcafe_v0.x.x / test_testcafe_v0.x.x_clientfunction.js View on Github external
test('Hammerhead code instrumentation', async() => {
    const location = await getLocation();

    await t.expect(location).eql('http://localhost:3000/fixtures/api/es-next/client-function/pages/index.html');
});
github TheBrainFamily / TheBrain2.0 / testing / testHelpers / TestCafeElement.js View on Github external
async assertIsVisible () {
    await t.expect(Selector(this.selector).exists).ok(`${this.selector} should be visible`)
  }
github gentics / mesh-ui / testcafe / page-object / editor / container-contents.ts View on Github external
export async function expectVisible() {
        await t.expect(Selector('mesh-container-contents').visible).ok('Container contents are not visible');
    }
github gentics / mesh-ui / testcafe / page-object / toast.ts View on Github external
async function expectMessage(msg: string, type: string) {
        await t
            .expect(Selector(`gtx-toast div.${type}`).withText(msg).exists)
            .ok(`Expected toast error message containing "${msg}"`);
    }
}
github TheBrainFamily / TheBrain2.0 / testing / testHelpers / TestCafeElement.js View on Github external
async assertNotVisible () {
    await t.expect(Selector(this.selector).exists).ok(`${this.selector} should be not visible`)
  }
}
github neos / neos-ui / Tests / checkPropTypes.js View on Github external
export default async function () {
    const {error} = await t.getBrowserConsoleMessages();
    if (error[0]) {
        console.log('These console errors were the cause of the failed test:', error);
    }
    await t.expect(error[0]).notOk();
}
github Soluto / tweek / e2e / ui / pages / Settings / index.js View on Github external
async open(identityType) {
    const button = this.find(identityType);
    const currentIdentity = new Identity(identityType);

    await t
      .expect(button.visible)
      .ok()
      .click(button)
      .expect(currentIdentity.container.visible)
      .ok();

    return currentIdentity;
  }