Skip to content

Instantly share code, notes, and snippets.

@jasonbyrne jasonbyrne/npmjs.js
Created Sep 5, 2019

What would you like to do?
Flagpole suite with Puppeteer
const { Flagpole } = require('flagpole');
const opts = {
headless: false,
width: 1280,
height: 600
const suite = Flagpole.suite('Basic Smoke Test of')
suite.browser("Search for Flagpole", opts)
.next('Verify homepage looks valid', async context => {
const heroContents = await context.waitForExists('#hero_contents');
const h1 = await heroContents.find('h1');
const cta = await heroContents.find('a[href="/products/"]');
context.assert(await h1.getText()).like('build amazing things');
context.assert(await cta.getText()).equals('See plans');
.next('Fill out the search box and submit', async context => {
const form = await context.find('form#search');
const input = await form.find('input[name="q"]');
await input.type('Flagpole');
context.assert(await input.getValue()).equals('Flagpole');
return form.submit();
.next('Validate search results page', async context => {
await context.waitForNavigation();
const main = await context.waitForExists('main');
const heading = await main.find('h2');
const searchResults = await main.findAll('section');
context.assert(await heading.getText())
.contains('packages found');
context.assert('Should be search results', searchResults)
return searchResults[0];
.next('First result should be Flagpole', async context => {
const firstResult = await context.result;
const title = await firstResult.find('h3');
const link = await title.getParent();
context.assert('Found search result title', title).exists();
'Title should say exactly flagpole',
await title.getText()
context.assert('Parent of title should exist', link)
'Parent of title should be an <a> tag',
await link.getTagName()
'Href should link to flagpole package',
await link.getAttribute('href')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.