How to use @open-wc/semantic-dom-diff - 4 common examples

To help you get started, we’ve selected a few @open-wc/semantic-dom-diff 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 open-wc / open-wc / packages / chai-dom-equals / chai-dom-equals.js View on Github external
try {
        new chai.Assertion(actualHTML).to.equal(expectedHTML);
      } catch (error) {
        /* eslint-disable no-console */
        console.log('LightDom Snapshot changed, want to accept the change:');
        console.log('');
        console.log(actualHTML);
        /* eslint-enable no-console */
        throw error;
      }

    // @ts-ignore
    } else if (utils.flag(this, 'dom')) {
      const expectedHTML = getDiffableHTML(value, args[0]);
      // @ts-ignore
      const actualHTML = getDiffableHTML(getOuterHtml(this._obj), args[0]);

      // use chai's built-in string comparison, log the updated snapshot on error
      try {
        new chai.Assertion(actualHTML).to.equal(expectedHTML);
      } catch (error) {
        /* eslint-disable no-console */
        console.log('Dom Snapshot changed, want to accept the change:');
        console.log('');
        console.log(actualHTML);
        /* eslint-enable no-console */
        throw error;
      }

    } else {
      // @ts-ignore
      _super.apply(this, [value, ...args]);
github open-wc / open-wc / packages / chai-dom-equals / chai-dom-equals.js View on Github external
const domEquals = _super => function handleDom(value, ...args) {
    // @ts-ignore
    if (utils.flag(this, 'shadowDom')) {
      const expectedHTML = getDiffableHTML(value, args[0]);
      // @ts-ignore
      const actualHTML = getDiffableHTML(getCleanedShadowDom(this._obj), args[0]);

      // use chai's built-in string comparison, log the updated snapshot on error
      try {
        new chai.Assertion(actualHTML).to.equal(expectedHTML);
      } catch (error) {
        /* eslint-disable no-console */
        console.log('ShadowDom Snapshot changed, want to accept the change:');
        console.log('');
        console.log(actualHTML);
        /* eslint-enable no-console */
        throw error;
      }

    // @ts-ignore
github open-wc / open-wc / packages / chai-dom-equals / chai-dom-equals.js View on Github external
const domEquals = _super => function handleDom(value, ...args) {
    // @ts-ignore
    if (utils.flag(this, 'shadowDom')) {
      const expectedHTML = getDiffableHTML(value, args[0]);
      // @ts-ignore
      const actualHTML = getDiffableHTML(getCleanedShadowDom(this._obj), args[0]);

      // use chai's built-in string comparison, log the updated snapshot on error
      try {
        new chai.Assertion(actualHTML).to.equal(expectedHTML);
      } catch (error) {
        /* eslint-disable no-console */
        console.log('ShadowDom Snapshot changed, want to accept the change:');
        console.log('');
        console.log(actualHTML);
        /* eslint-enable no-console */
        throw error;
      }

    // @ts-ignore
    } else if (utils.flag(this, 'lightDom')) {
      const expectedHTML = getDiffableHTML(value, args[0]);
github open-wc / open-wc / packages / chai-dom-equals / chai-dom-equals.js View on Github external
try {
        new chai.Assertion(actualHTML).to.equal(expectedHTML);
      } catch (error) {
        /* eslint-disable no-console */
        console.log('ShadowDom Snapshot changed, want to accept the change:');
        console.log('');
        console.log(actualHTML);
        /* eslint-enable no-console */
        throw error;
      }

    // @ts-ignore
    } else if (utils.flag(this, 'lightDom')) {
      const expectedHTML = getDiffableHTML(value, args[0]);
      // @ts-ignore
      const actualHTML = getDiffableHTML(this._obj.innerHTML, args[0]);

      // use chai's built-in string comparison, log the updated snapshot on error
      try {
        new chai.Assertion(actualHTML).to.equal(expectedHTML);
      } catch (error) {
        /* eslint-disable no-console */
        console.log('LightDom Snapshot changed, want to accept the change:');
        console.log('');
        console.log(actualHTML);
        /* eslint-enable no-console */
        throw error;
      }

    // @ts-ignore
    } else if (utils.flag(this, 'dom')) {
      const expectedHTML = getDiffableHTML(value, args[0]);

@open-wc/semantic-dom-diff

To compare dom and shadow dom trees. Part of open-wc recommendations

MIT
Latest version published 5 months ago

Package Health Score

92 / 100
Full package analysis

Popular @open-wc/semantic-dom-diff functions