量角器测试中async函数中的log4js-protractor-appender不会打印出任何内容

时间:2019-02-11 01:05:27

标签: javascript typescript protractor e2e-testing log4js-node

我正在尝试将记录器添加到我的量角器,黄瓜,打字稿项目中。我浏览了几篇文章,但没有找到符合目的的文章。

以下是我写的SO文章:I am finding trouble using log4js-protractor-appender

并从此处Error with log4js configuration: must have a property "appenders" of type object

但是,我的步骤定义是以异步方式编写的,并不真正在控制台上打印出browser.logger.info语句。

有人可以帮我提供量角器打字稿的例子吗?下面是我的项目代码

stepdefs.ts

Given(/^I am on the Google site for "(.*?)"$/, async (text) => {
    await toplinks.navigate_SearchText();
    let textUI = await toplinks.getText_Search();
    browser.logger.info("This is what I am looking for");        
    await expect(textUI).equal('Financial Advisors');
});

conf.ts

    beforeLaunch:function(){
            if (fs.existsSync('./logs/ExecutionLog.log')) {
                fs.unlinkSync('./logs/ExecutionLog.log')
            }
            log4js.configure({
                appenders: {
                    fileLog: { type: 'file', filename: './logs/ExecutionLog.log' },
                    console: { type: 'log4js-protractor-appender' }
                },
                categories: {
                    file: { appenders: ['fileLog'], level: 'error' },
                    another: { appenders: ['console'], level: 'trace' },
                    default: { appenders: ['console', 'fileLog'], level: 'trace' }
                }
            });
        },

onPrepare: () => {
        browser.ignoreSynchronization = true;
        browser.manage().timeouts().implicitlyWait(12000);
        browser.manage().window().maximize();
        browser.logger = log4js.getLogger('another');
        Reporter.createDirectory(jsonReports);      
    },

0 个答案:

没有答案