How to use the jsdom.JSDOM.fromFile function in jsdom

To help you get started, we’ve selected a few jsdom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ProjectEvergreen / greenwood / test / cli / cases / build.config.workspace-custom / build.config.workspace-custom.spec.js View on Github external
beforeEach(async function() {
        dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'about', './index.html'));
      });
github ProjectEvergreen / greenwood / test / cli / cases / build.default.workspace-template-app / build.default.workspace-template-app.spec.js View on Github external
beforeEach(async function() {
        dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html'));
      });
github ProjectEvergreen / greenwood / test / cli / cases / build.default.workspace-template-page / build.default.workspace-template-page.spec.js View on Github external
before(async function() {
        dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html'));
      });
github ProjectEvergreen / greenwood / test / cli / cases / build.config.meta / build.config.meta.spec.js View on Github external
beforeEach(async function() {
        dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'about', './index.html'));
      });
github arendjr / selectivity / tests / unit / event-listener.js View on Github external
tape('event-listener: it supports capturing an event', function(test) {
    test.plan(1);

    JSDOM.fromFile('tests/resources/testcase-event-listener.html').then(function(dom) {
        var window = dom.window;

        global.document = window.document;
        global.window = window;

        var numCallbacksCalled = 0;
        function callback() {
            numCallbacksCalled++;
        }

        var events = new EventListener(document.body);
        events.on('blur', '.some-class', callback);

        var event = new window.FocusEvent('blur', { bubbles: false, view: window });
        document.querySelector('.another-class').dispatchEvent(event);
github clebert / pageobject / @pageobject / web / src / JSDOMAdapter.ts View on Github external
public async goto(url: string): Promise {
    await this.quit();

    const options: FromFileOptions = {runScripts: 'dangerously'};

    this._jsdom = /file:\/\//.test(url)
      ? await JSDOM.fromFile(url.slice(7), options)
      : await JSDOM.fromURL(url, options);
  }
github imfunniee / gitfolio / populate.js View on Github external
module.exports.updateHTML = (username, opts) => {
  const { includeFork, twitter, linkedin, medium, dribbble } = opts;
  //add data to assets/index.html
  jsdom
    .fromFile(`${__dirname}/assets/index.html`, options)
    .then(function(dom) {
      let window = dom.window,
        document = window.document;
      (async () => {
        try {
          console.log("Building HTML/CSS...");
          const repos = await getRepos(username, opts);

          for (var i = 0; i < repos.length; i++) {
            let element;
            if (repos[i].fork == false) {
              element = document.getElementById("work_section");
            } else if (includeFork == true) {
              document.getElementById("forks").style.display = "block";
              element = document.getElementById("forks_section");
github facebook / create-react-app / packages / react-scripts / fixtures / kitchensink / template / integration / initDOM.js View on Github external
new Promise(async (resolve, reject) => {
    try {
      const host = process.env.E2E_URL || 'http://www.example.org/spa:3000';
      const url = `${host}#${feature}`;

      let window;

      if (process.env.E2E_FILE) {
        window = (
          await JSDOM.fromFile(file, {
            pretendToBeVisual: true,
            resources: fileResourceLoader,
            runScripts: 'dangerously',
            url,
          })
        ).window;
      } else {
        window = (
          await JSDOM.fromURL(url, {
            pretendToBeVisual: true,
            resources: 'usable',
            runScripts: 'dangerously',
          })
        ).window;
      }
github bennypowers / rollup-plugin-modulepreload / index.js View on Github external
async generateBundle({ format, dir }, bundle) {
      if (format !== 'es') return;
      const dom = await JSDOM.fromFile(index);

      const createLinkFromChunk = compose(
        createLinkElement(dom),
        createLinkHref((typeof prefix !== "undefined") ? prefix : dir),
        getPath,
      );

      const appendToDom = link =>
        dom.window.document.head.appendChild(link);

      await getPreloadChunks(shouldPreload, bundle)
        .then(map(createLinkFromChunk))
        .then(map(appendToDom));

      await writeFile(path.resolve(index), dom.serialize(), 'utf-8')
    }