Created
September 10, 2020 17:05
-
-
Save jasonbyrne/b87786e571c4d142bd36223a19bf650a to your computer and use it in GitHub Desktop.
Flagpole <3s Ngrok
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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