question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tests stall when calling `context.config`

See original GitHub issue

Bug Report

Current Behavior I’m trying to upgrade from Probot 7 to 9 but my jest tests stall when the app calls context.config, for example:

const config = await context.config('issue-branch.yml', {})

I have different tests that check if the app works with and without configs in the target repo. For example, to check if the app works without configuration I mock the network call like this:

nock('https://api.github.com')
    .get('/repos/robvanderleek/create-issue-branch/contents/.github/issue-branch.yml')
    .reply(404)

With Probot 7 this works fine but after upgrading to 9 the test stalls and I eventually receive a Jest timeout (Timeout - Async callback was not invoked within the 15000ms timeout specified by jest.setTimeout.)

Expected behavior/code

A call to await context.config('issue-branch.yml', {}) should result in a network call that I can mock.

Perhaps I’m misunderstanding how this work in version 9 so I’m not sure this is a bug or expected behaviour.

Environment

  • Probot version(s): 9.6.3
  • Node/npm version: 12.12.0
  • OS: macOS

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
igalarzabcommented, Nov 1, 2021

This is so weird… I can see in the recent-probot-and-nock-versions branch that the bug is not reproducible… but I still have the same problem using the exact same versions of probot, nock and jest 😕

Thanks for the repo!

1reaction
tianhaoz95commented, Aug 22, 2020

Nvm I just figured out:

const rawContent = fs.readFileSync(path.join(__dirname, '/fixtures/basic-config.yml'))
const contentBuf = Buffer.from(rawContent)
const encodedContent = contentBuf.toString('base64')
nock('https://api.github.com')
  .get('/repos/tianhaoz95/.github/contents/.github/approveman.yml')
  .reply(200, {
    type: 'file',
    encoding: 'base64',
    size: encodedContent.length,
    name: 'approveman.yml',
    path: '.github/contents/.github/approveman.yml',
    content: encodedContent
  })
Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring context tests can't find config locations - Stack Overflow
Now I'm trying to use Spring's transactional test base classes which take the config locations and load the context for me.
Read more >
Testing Your Application - Quarkus
Use the quarkus.resteasy.path config value instead if you want a custom context path. 5.1. TestHTTPResource. You can the use the ...
Read more >
Using RCU's CPU Stall Detector
This kernel configuration parameter defines the period of time that RCU will wait from the beginning of a grace period until it issues...
Read more >
Why tests pass locally but fail in Jenkins | Object Partners
I've seen this occur when the test assertions are actually completed before the async calls finish. If possible, you should run your assertions ......
Read more >
dotnet test command - .NET CLI | Microsoft Learn
When you run this command, it initiates an asynchronous background download of advertising manifests for workloads. If the download is still ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found