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

test(data-loader): move jest.setTimeout to top of the file #1024

Merged
merged 2 commits into from
Jul 27, 2021

Conversation

zaki-yama
Copy link
Contributor

Why

Fix #1023 .

What

move jest.setTimeout to top of the file.

How to test

I confirmed that jest.setTimeout works in modified code by the following steps:

  • Replace jest.setTimeout(30000) to jest.setTimeout(5) (set very small timeout ms)
  • Run yarn test under packages/data-loader
  • The test fails and the error message says "Exceeded timeout of 5 ms for a test."
 FAIL  src/__tests__/main.test.ts (5.099 s)
  ● main › should throw error when no commands are passed

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

      26 |
      27 | describe("main", () => {
    > 28 |   it("should throw error when no commands are passed", () => {
         |   ^
      29 |     return checkRejectArg({
      30 |       arg: "",
      31 |       errorMessage: "Not enough non-option arguments: got 0, need at least 1",

      at __tests__/main.test.ts:28:3
      at Object.<anonymous> (__tests__/main.test.ts:27:1)

Checklist

  • Read CONTRIBUTING.md
  • Updated documentation if it is required.
  • Added tests if it is required.
  • Passed yarn lint and yarn test on the root directory.

@zaki-yama zaki-yama requested review from a team, tasshi-me and shintaroNagata and removed request for a team July 21, 2021 09:11
@github-actions github-actions bot added the pkg: data-loader @kintone/data-loader label Jul 21, 2021
beforeEach(() => {
jest.setTimeout(10000);
});
jest.setTimeout(30000);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to extend the timeout, and have no specific reason why I chose 30000.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: https://jestjs.io/docs/jest-object#jestsettimeouttimeout

This only affects the test file from which this function is called.

@zaki-yama zaki-yama self-assigned this Jul 21, 2021
Copy link
Member

@tasshi-me tasshi-me left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

@tasshi-me tasshi-me merged commit c48d7d0 into master Jul 27, 2021
@tasshi-me tasshi-me deleted the fix/jest-settimeout branch July 27, 2021 02:09
tasshi-me pushed a commit that referenced this pull request Jul 4, 2022
* test: move `jest.setTimeout` to top of the file

ref. jestjs/jest#11500

* chore: extend timeout to 30 sec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: data-loader @kintone/data-loader
Projects
None yet
Development

Successfully merging this pull request may close these issues.

yarn test sometimes fails due to timeout
2 participants