Skip to content

Instantly share code, notes, and snippets.

@trotzig

trotzig/.happo.js

Created Jan 8, 2019
Embed
What would you like to do?
Example of using happo-plugin-scrape with a wrapper element
const path = require('path');
const { RemoteBrowserTarget } = require('happo.io');
const happoScrapePlugin = require('happo-plugin-scrape');
function commonWrapper(html) {
return `
<div class="application-wrapper">
<div style="width:100%" class="od-homepage">${html}</div>
</div>
`;
}
module.exports = {
apiKey: process.env.APIKEY,
apiSecret: process.env.APISECRET,
type: 'plain',
plugins: [
happoScrapePlugin({
pages: [
{
url: 'https://www.opendoor.com',
wrapper: commonWrapper,
examples: [
{
name: 'Navigation',
selector: '.od-full-header',
},
{
name: 'Sell in a few steps',
selector: '#how-it-works .regular-container',
},
{
name: 'Get an offer',
selector: '.test-default',
},
{
name: 'Locations',
selector: '#locations'
},
{
name: 'Footer',
selector: '.od-full-footer'
}
],
},
],
}),
],
targets: {
// The first part ('firefox-desktop' in this case) is just a name we give
// the specific browser target. You'll see this name in the reports generated
// as part of a happo run.
edge: new RemoteBrowserTarget('edge', {
viewport: '1024x768',
}),
'chrome-mobile': new RemoteBrowserTarget('chrome', {
viewport: '400x640',
}),
chrome: new RemoteBrowserTarget('chrome', {
viewport: '1024x768',
}),
safari: new RemoteBrowserTarget('safari', {
viewport: '1024x768',
}),
'internet explorer': new RemoteBrowserTarget('internet explorer', {
viewport: '1024x768',
}),
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment