Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

probot.receive in tests throws an error #960

Closed
Jake-Gillberg opened this issue Jul 7, 2019 · 3 comments

Comments

@Jake-Gillberg
Copy link

commented Jul 7, 2019

Bug Report

The default tests for the ts-basic application template throws an error at probot.receive

Current Behavior
This test throws a typeError that seems to stem from come from @octokit

import nock from 'nock'
// Requiring our app implementation
import myProbotApp from '../src'
import { Probot } from 'probot'
// Requiring our fixtures
import payload from './fixtures/issues.opened.json'
const issueCreatedBody = { body: 'Thanks for opening this issue!' }

nock.disableNetConnect()

describe('My Probot app', () => {
  let probot: any

  beforeEach(() => {
    probot = new Probot({ id: 123, cert: 'test' })
    // Load our app into probot
    const app = probot.load(myProbotApp)

    // just return a test token
    app.app = () => 'test'
  })

  test('creates a passing check', async () => {
    // Test that we correctly return a test token
    nock('https://api.github.com')
      .post('/app/installations/2/access_tokens')
      .reply(200, { token: 'test' })

    // Test that a commented is posted
    nock('https://api.github.com')
      .post('/repos/hiimbex/testing-things/issues/1/comments', (body: any) => {
        expect(body).toMatchObject(issueCreatedBody)
        return true
      })
      .reply(200)

    // Recieve a webhook event
    await probot.receive({ name: 'issues', payload })
  })
})

However, on npm run test we get an error:

  ● My Probot app › creates a passing check

    TypeError: this.app.getSignedJsonWebToken is not a function

      39 | 
      40 |     // Recieve a webhook event
    > 41 |     await probot.receive({ name: 'issues', payload })
         |                  ^
      42 |   })
      43 | })
      44 | 

Expected behavior/code
Test Passes

Environment

  • Probot version(s): 9.2.15
  • Node/npm version: 6.10.0
  • OS: Debian 9.8

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@issue-label-bot

This comment has been minimized.

Copy link

commented Jul 7, 2019

Issue-Label Bot is automatically applying the label bug 🐞 to this issue, with a confidence of 0.97. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@welcome

This comment has been minimized.

Copy link

commented Jul 7, 2019

Thanks for opening this issue. A contributor should be by to give feedback soon. In the meantime, please check out the contributing guidelines and explore other ways you can get involved.

@Jake-Gillberg

This comment has been minimized.

Copy link
Author

commented Jul 7, 2019

Oops, the test itself was broken because of this line app.app = () => 'test'. This was, however, a default test that came with create-probot-app. I'll open up an issue over there.

Fixed by removing that line and changing probot = new Probot({ id: 123, cert: 'test' }) to probot = new Probot({ id: 123, githubToken: 'test' }).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.