Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmay-browserstack committed Jul 25, 2024
1 parent f847147 commit f46820b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/.storybook/snapshot.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const First = () => (

First.parameters = {
percy: {
domTransformation: '(documentElement) => { documentElement.querySelectorAll(".removeMe").forEach(ele => ele.remove()); }'
domTransformation: '(documentElement) => { documentElement.querySelectorAll(".removeMe").forEach(ele => ele.remove()); }',
enableJavascript: false // this should be priotised over global config
}
}
export const Second = () => (
Expand Down
18 changes: 18 additions & 0 deletions test/storybook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,24 @@ describe('percy storybook', () => {
expect(callArgs[1][0].domSnapshot).toEqual(previewDOM);
});

it('uses the preview dom when javascript is enabled', async () => {
fs.writeFileSync('.percy.yml', [
'version: 2',
'snapshot:',
' enableJavaScript: true'
].join('\n'));

// eslint-disable-next-line import/no-extraneous-dependencies
let { Percy } = await import('@percy/core');
spyOn(Percy.prototype, 'snapshot').and.callThrough();

await storybook(['http://localhost:9000', '--include=First', '--verbose']);

expect(logger.stderr).toEqual(jasmine.arrayContaining([
'[percy:storybook] Loading story: Snapshot: First'
]));
});

it('removes element when domTransformation is passed', async () => {
// eslint-disable-next-line import/no-extraneous-dependencies
let { Percy } = await import('@percy/core');
Expand Down

0 comments on commit f46820b

Please sign in to comment.