Skip to content

rewrite cheerio with newer jsdom/jquery #24

@titaniumbones

Description

@titaniumbones

This would also close #22 #21 and #20.

It's possible to load the page asynchronously in jsdom & then add jquery. This allows the querying of computed css values.

Here is some code that works:

  before(async function() {
    let jsdom = await JSDOM.fromFile("05/index.html", {
      resources: "usable",
      runScripts: "dangerously"
    });
    
    await new Promise(resolve =>
      jsdom.window.addEventListener("load", resolve)      
    );
    let window  = jsdom.window;
    let {document } = global.document = window;
    // global scope absolutely required unfortunately
    let $ = global.$ = require('jquery')(window);
  });

tests then become generally more reliable.

working on this in another branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions