Skip to content

v2.1.0

Choose a tag to compare

@Robdel12 Robdel12 released this 25 Mar 16:35
· 457 commits to master since this release
6c5fedc

What's new?

You can now pass your own domTransformation option to percySnapshot. This will allow you to add elements to the clone of the DOM that Percy captures (#188). For example:

test('passing a custom DOM transform', async function(assert) {
  await visit('/');
  assert.equal(currentURL(), '/');

  await percySnapshot(assert, {
    domTransformation: function(clonedDom) {
      let $scopedRoot = clonedDom.querySelector('#ember-testing');
      let $h1 = document.createElement('h1');
      $h1.innerText = 'Hello modified DOM!';
      $scopedRoot.appendChild($h1);

      return clonedDom;
    }
});

This could be useful if you have an Ember addon which adds DOM elements outside of the Ember application root (which is ember-testing in tests). You could then collect those elements and add them back into the DOM clone Percy captures.