首页 > 解决方案 > 赛普拉斯任务。然后不按预期工作

问题描述

我有一个问题,我需要帮助来了解会发生什么。这段代码正常工作:

tfc.logout()
            .then(() => {
                cy.log('Before account affectation');
                cy.task('createTestAccount')
                    .then((acc) => {
                        cy.log(acc);        <-- acc is not empty
                        account = acc;
                        expect(account.id).to.exist;
                    });
            });

但是这个(在我的理解中应该是一样的不起作用):

tfc.logout()
            .then(() => {
                cy.log('Before account affectation');
                return cy.task('createTestAccount');
            })
            .then((acc) => {
                cy.log(acc);             <---- acc is null
                account = acc;
                expect(account.id).to.exist;
            });

任何帮助,将不胜感激

标签: taskcypress

解决方案


推荐阅读