【问题标题】:How to get passed or failed test case name in the puppeteer如何在 puppeteer 中获得通过或失败的测试用例名称
【发布时间】:2019-08-22 20:30:36
【问题描述】:

我需要使用 TestRail API 将 puppeteer-jest 测试框架与 TestRail 集成。但为此,我需要知道哪些测试失败了,哪些测试通过了

我在官方 GitHub 存储库和 Jest 站点中搜索一些信息。但没什么。

测试:

describe('Single company page Tests:', () => {
    let homePage;
    beforeAll(async () => {
        homePage = await addTokenToBrowser(browser);
    }, LOGIN_FLOW_MAX_TIME);

    it('Open the company page from the list', async done => {
        await goto(homePage, LIST_PAGE_RELATIVE_PATH);
        await listPage.clickSearchByCompanyName(homePage);
        await addCompanyNamePopup.isPopupDisplayed(homePage);
        await addCompanyNamePopup.fillCompanyName(homePage, companies.century.link);
        await addCompanyNamePopup.clickNext(homePage);
        await addCompanyNamePopup.fillListName(homePage, listNames[0]);
        await addCompanyNamePopup.clickSave(homePage);
        await addCompanyNamePopup.clickViewList(homePage);
        const nextPage = await clickCompanyName(homePage, browser, companies.century.name);
        await companyPage.isOverviewTabPresent(nextPage);
        await companyPage.isPeopleTabPresent(nextPage);
        await companyPage.isSocialTabPresent(nextPage);
        await companyPage.isFinanceTabPresent(nextPage);
        await companyPage.isLeaseTabPresent(nextPage);
        await homePage.close();
        done();
    });
}

我希望获得所有通过和失败的测试用例名称,并将其与测试用例的名称及其结果一起写入 JSON。 其实我什么都没有。

【问题讨论】:

    标签: javascript json jestjs puppeteer


    【解决方案1】:

    您可以使用我喜欢在我的 github 中使用的真/假断言方法 project。 例如,尝试使用简单的assert 将大小写锚定到某个最终选择器:

        describe('E2E testing', () => {
            it('[Random Color Picker] color button clickable', async () => {
                // Setup
                let expected = true;
                let expectedCssLocator = '#color-button';
                let actual;
                // Execute
                let actualPromise = await page.waitForSelector(expectedCssLocator);
                if (actualPromise != null) {
                    await page.click(expectedCssLocator);
                    actual = true;
                }
                else
                    actual = false;
                // Verify
                assert.equal(actual, expected);
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-18
      • 1970-01-01
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多