Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix enableJavaScript default for snapshot discovery #453

Merged
merged 2 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/percy.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export default class Percy {
// open a new browser page
page = await this.browser.page({
networkIdleTimeout: this.config.discovery.networkIdleTimeout,
enableJavaScript: domSnapshot ? conf.enableJavaScript : true,
enableJavaScript: conf.enableJavaScript ?? !domSnapshot,
requestHeaders: discovery.requestHeaders,
authorization: discovery.authorization,
userAgent: discovery.userAgent,
Expand Down
35 changes: 35 additions & 0 deletions packages/core/test/discovery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,41 @@ describe('Discovery', () => {
]);
});

it('does not capture javascript files when not enabled', async () => {
server.reply('/javascript.js', () => [200, 'text/javascript', 'window.location = "/"']);

let jsDOM = dedent`
<html><head></head><body>
<script src="/javascript.js"></script>
</body></html>
`;

await percy.snapshot({
name: 'test snapshot',
url: 'http://localhost:8000',
domSnapshot: jsDOM
});

await percy.idle();

let paths = server.requests.map(r => r[0]);
expect(paths.sort()).not.toContain('/javascript.js');

expect(captured[0]).toEqual([
jasmine.objectContaining({
attributes: jasmine.objectContaining({
'resource-url': jasmine.stringMatching(/^\/percy\.\d+\.log$/)
})
}),
jasmine.objectContaining({
attributes: jasmine.objectContaining({
'resource-url': 'http://localhost:8000/',
'is-root': true
})
})
]);
});

it('logs detailed debug logs', async () => {
percy.loglevel('debug');

Expand Down