Skip to content

Instantly share code, notes, and snippets.

@jasonbyrne
Created September 10, 2020 17:05
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/b87786e571c4d142bd36223a19bf650a to your computer and use it in GitHub Desktop.
Save jasonbyrne/b87786e571c4d142bd36223a19bf650a to your computer and use it in GitHub Desktop.
Flagpole <3s Ngrok
import flagpole from "flagpole";
import * as ngrok from "ngrok";
flagpole("Just a basic webhook callback", async (suite) => {
// Create webhook scenario
const webhook = await suite
.scenario("Wait for a webhook", "resource")
.webhook("GET /foo")
.next(async (context) => {
context.comment("Webhook was hit!");
})
.server();
// Create ngrok tunnel pointing to the localhost port
const url = await ngrok.connect(webhook.port);
// Hit the ngrok url (which triggers the webhook)
await suite
.scenario("hit webhook", "resource")
.open(`${url}/foo`)
.next(async (context) => {
context.assert(context.response.body).equals("OK");
})
.waitForFinished();
// Disconnect from ngrok
await ngrok.disconnect();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment