How to check something in the <head> section

Hi everyone,

I’m really new into CodeceptJS testing. I was trying to check for a project if a favicon is set, or if the meta description was set into the section.

I came to the conclusion that it was not possible to check all the section of an html file. Do you think there is a way to do something like this?

Thanks!

Use the cheerio library.

cheerio

Tiny, fast, and elegant implementation of core jQuery designed specifically for the server

You can pass the html of a page to this library

example…

    const source = await I.grabHTMLFrom('html');  
    const $customer = cheerio.load(source);  

    $customer('body').find( 'a' ).each( (i,element) => {  
    let href = $customer(element).attr('href');  
    let text = $customer(element).text();  

    // etc  
    });

Thanks, I will try it and give you my feedback asap