Build Mocha test dynamically after getting data from webdriver.io

后端 未结 3 1258
南旧
南旧 2021-01-19 09:32

I\'m looking for a solution to define Mocha tests after getting data asynchronously.

For now, I use gulp-webdriver to getting HTML content with Selenium. And I wan

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-19 09:52

    It doesn't seem possible to dynamically create it() tests with mocha.

    I finally organise my test like this :

    it('Check if all tag have attribute', function() {
            var errors = [];
            elements.forEach(function(element, index, array) {
                var $ = cheerio.load(element);
                var tag = $(tagName);
                if (tag.length) {
                    if (!tag.attr(tagAttr)) errors.push(element);
                }
            });
            expect(errors).to.be.empty;
        }
    }
    

提交回复
热议问题