Skip to content

Commit

Permalink
tests added for core package
Browse files Browse the repository at this point in the history
  • Loading branch information
itsjwala committed Oct 30, 2023
1 parent acff601 commit 327370a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/test/percy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('Percy', () => {
});

// expect required arguments are passed to PercyDOM.serialize
expect(evalSpy.calls.allArgs()[3]).toEqual(jasmine.arrayContaining([jasmine.anything(), { enableJavaScript: undefined, disableShadowDOM: true, domTransformation: undefined }]));
expect(evalSpy.calls.allArgs()[3]).toEqual(jasmine.arrayContaining([jasmine.anything(), { enableJavaScript: undefined, disableShadowDOM: true, domTransformation: undefined, reshuffleInvalidTags: undefined }]));

expect(snapshot.url).toEqual('http://localhost:8000/');
expect(snapshot.domSnapshot).toEqual(jasmine.objectContaining({
Expand Down
24 changes: 23 additions & 1 deletion packages/core/test/snapshot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,8 @@ describe('Snapshot', () => {
domSnapshot: {
html: `<img src="${resource.url}"/>`,
warnings: ['Test serialize warning'],
resources: [resource, textResource]
resources: [resource, textResource],
hints: ['DOM elements found outside </body>']
}
});

Expand Down Expand Up @@ -1301,5 +1302,26 @@ describe('Snapshot', () => {
expect(root.id).toEqual(sha256hash(injectedDOM));
expect(root.attributes).toHaveProperty('base64-content', base64encode(injectedDOM));
});

it('warns when domSnapshot hints of invalid tags', async () => {
await percy.snapshot({
name: 'Serialized Snapshot',
url: 'http://localhost:8000',
domSnapshot: {
html: '',
warnings: [],
resources: [],
hints: ['DOM elements found outside </body>']
}

});

expect(logger.stderr).toEqual([
'[percy] DOM elements found outside </body>, percyCSS might not work'
]);
expect(logger.stdout).toEqual([
'[percy] Snapshot taken: Serialized Snapshot'
]);
});
});
});

0 comments on commit 327370a

Please sign in to comment.