Skip to content

Instantly share code, notes, and snippets.

@jasonbyrne
Created August 15, 2019 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonbyrne/ec3dcfc71bfb45e405edbba0c8b2b787 to your computer and use it in GitHub Desktop.
Save jasonbyrne/ec3dcfc71bfb45e405edbba0c8b2b787 to your computer and use it in GitHub Desktop.
Sample Test Suite created in the Flagpole Walkthrough on August 15, 2019
const { Flagpole } = require('flagpole');
const searchTerm = 'Flagpole QA';
const suite = Flagpole.suite('Basic Smoke Test of Site')
.base('https://www.google.com');
suite.html('Homepage Loads')
.open('/')
.next('Test the basic headers', (ctx) => {
ctx.assert('Status is 200', ctx.response.statusCode)
.equals(200);
})
.next('Fill out the search form', async (ctx) => {
const form = await ctx.find('form');
const searchBox = await ctx.find('input[name="q"]');
ctx.assert('Form exists on the page', form).exists();
ctx.assert(searchBox).exists();
await form.fillForm({
q: searchTerm
});
ctx.assert(await searchBox.getValue()).equals(searchTerm);
form.submit('Submit form and check results page', async function () {
const searchInputBox = await this.find('input[name="q"]');
this.assert('Search input box should have the value we typed', await searchInputBox.getValue())
.equals(searchTerm);
const npmResult = await this.find('a[href*="npm"]');
this.assert('Link to Flagpole NPM is on first page of results', npmResult).exists();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment