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

I seem to always get 2 failed tests when running npm t #42

Closed
alfonsusac opened this issue Oct 25, 2022 · 3 comments
Closed

I seem to always get 2 failed tests when running npm t #42

alfonsusac opened this issue Oct 25, 2022 · 3 comments
Labels
question Further information is requested

Comments

@alfonsusac
Copy link

Hello, I tried to clone this repository to work on adding the status feature.
But i cannot seem to get npm t running.

This is the result

 FAIL  dist/createBot.test.js (37.59 s)
  send functions
    √ sends text (628 ms)
    √ sends message (502 ms)
    √ sends image (580 ms)
    √ sends document (553 ms)
    √ sends audio (610 ms)
    √ sends video (522 ms)
    √ sends sticker (654 ms)
    √ sends location (517 ms)
    √ sends template (589 ms)
    √ sends contacts (508 ms)
    √ sends reply button (612 ms)
    √ sends list (540 ms)
  server functions
    √ invalid webhook token (37 ms)
    × verify webhook token (3 ms)
    √ send invalid body (16 ms)
    × listen for new messages (30014 ms)

  ● server functions › verify webhook token

    connect ECONNREFUSED 127.0.0.1:80



  ● server functions › listen for new messages

    connect ECONNREFUSED 127.0.0.1:80



  ● server functions › listen for new messages

    connect ECONNREFUSED 127.0.0.1:80



  ● server functions › listen for new messages

    connect ECONNREFUSED 127.0.0.1:80



  ● server functions › listen for new messages

    connect ECONNREFUSED 127.0.0.1:80



  ● server functions › listen for new messages

    connect ECONNREFUSED 127.0.0.1:80



  ● server functions › listen for new messages

    connect ECONNREFUSED 127.0.0.1:80



  ● server functions › listen for new messages

    connect ECONNREFUSED 127.0.0.1:80



  ● server functions › listen for new messages

    connect ECONNREFUSED 127.0.0.1:80



  ● server functions › listen for new messages

    connect ECONNREFUSED 127.0.0.1:80



  ● server functions › listen for new messages

    connect ECONNREFUSED 127.0.0.1:80



  ● server functions › listen for new messages

    thrown: "Exceeded timeout of 30000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      265 |
      266 |   // eslint-disable-next-line no-async-promise-executor
    > 267 |   test('listen for new messages', (): Promise<void> => new Promise(async (resolve, reject) => {
          |   ^
      268 |     const payloads = [
      269 |       {
      270 |         from: '12345678',

      at src/createBot.test.ts:267:3
      at Object.<anonymous> (src/createBot.test.ts:194:1)

Test Suites: 1 failed, 1 total
Tests:       2 failed, 14 passed, 16 total
Snapshots:   0 total
Time:        37.783 s, estimated 39 s
Ran all test suites matching /dist/i.

I tried using various webhook_path but it seem to keep getting 403 (forbidden)
Here is my webhook path

WEBHOOK_PATH="http://localhost:3000/webhook/whatsapp"

I also tried manually using rest api

GET http://localhost:3000/webhook/whatsapp?hub.mode=subscribe&hub.challenge=random&hub.verify_token=41ESBjuy5E

But gets 403 Forbidden instead.

I am running on Windows 10.

I also want to know what WEBHOOK_PATH do you use?

@tawn33y
Copy link
Owner

tawn33y commented Oct 25, 2022

Hi @alfonsusac,

It seems that your tests are trying to access the server via port 80 instead of port 3000, ie 127.0.0.1:80, which is why the tests timeout since the server is unreachable. Are you setting the port somewhere?

Also, have you set up the .env file correctly? Please ensure the verify token you're passing in via the url is the same as the one in the .env file, and try seeing if you will still get a 403 error.

GET http://localhost:3000/webhook/whatsapp?hub.mode=subscribe&hub.challenge=random&hub.verify_token=41ESBjuy5E
FROM_PHONE_NUMBER_ID=""
ACCESS_TOKEN=""
VERSION=""
TO=""
WEBHOOK_VERIFY_TOKEN="41ESBjuy5E"
WEBHOOK_PATH="/webhook/whatsapp"

See above also on how I set the webhook path.

@tawn33y
Copy link
Owner

tawn33y commented Nov 29, 2022

@alfonsusac did this work?

@tawn33y tawn33y added the question Further information is requested label Nov 29, 2022
@alfonsusac
Copy link
Author

Yes it worked, if it had not worked, I would not be able to ask for pull request

@tawn33y tawn33y closed this as completed Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants