probot: TypeError raised with test example from docs

Bug Report

Current Behavior

When running the example test from https://github.com/probot/probot/blob/master/docs/testing.md with my Probot app, this exception is raised:

TypeError: Cannot destructure property 'getRouter' of 'undefined' as it is undefined.

Expected behavior/code

No exception is raised.

Environment

  • Probot version(s): v11.0.1
  • Node/npm version: v15.4.0
  • OS: macOS Catalina 10.15.7 (19H15)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 23 (19 by maintainers)

Most upvoted comments

@peey the problem that this issue was opened for has been resolved. commenting on a closed issue can easily be overlooked by maintainers, plus you are reporting a new issue even if it could fit in the description of this existing issue. the best way to get appropriate attention to this problem would be for you to open a new issue (but feel free to to link to it from this one)

Yes, can you please create a separate issue?

Sure, will do.

Sorry for the fuss about that, no actual bug here, it was just as you suggested, i.e. values not properly read from .env file as expected, hence undefined in the previous snippet.

Installing https://github.com/motdotla/dotenv as dep and simply adding a require('dotenv').config() does the trick:

const { Server, Probot } = require('probot')
const app = require('./app')

require('dotenv').config()
const { env } = process
const appId = env.APP_ID
const privateKey = env.PRIVATE_KEY
const secret = env.WEBHOOK_SECRET

const server = new Server({
  Probot: Probot.defaults({ appId, privateKey, secret })
})

server.expressApp.set('trust proxy', true)
server.load(app)
server.start()
<div> GitHub</div><div>motdotla/dotenv</div><div>Loads environment variables from .env for nodejs projects. - motdotla/dotenv</div>