Skip to content

Conversation

@mikehardy
Copy link
Contributor

Summary:

the jdk doctor fix command is using "downloadAndUnzip", but the test
was mocking / spying on "unzip", this fixes the test to mock/spy on
the method actually used, patterned after the android studio test

This is the failure I see:

 FAIL  packages/cli-doctor/src/tools/healthchecks/__tests__/jdk.test.ts (34.812 s)
  ● jdk › downloads and unzips JDK on Windows when missing

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

      72 |   });
      73 |
    > 74 |   it('downloads and unzips JDK on Windows when missing', async () => {
         |   ^
      75 |     const loader = new tools.NoopLoader();
      76 |     const loaderSucceedSpy = jest.spyOn(loader, 'succeed');
      77 |     const loaderFailSpy = jest.spyOn(loader, 'fail');

      at packages/cli-doctor/src/tools/healthchecks/__tests__/jdk.test.ts:74:3
      at Object.<anonymous> (packages/cli-doctor/src/tools/healthchecks/__tests__/jdk.test.ts:20:1)

Test Plan:

It's literally made of test ;-) - I always start working in a repository by checking it out, and running all it's tests. I needed this PR in order to successfully run yarn test against tip of master branch in my macos environment.

Technically this also means there is a false-positive in CI, as yarn tests:ci:unit is passing, I think that's because unzip is called (after the download) so the test assertion that the spy is called passes, and in the CI environment it downloads quickly enough not to hit the timeout I get locally, so it passes the test.

the jdk doctor fix command is using "downloadAndUnzip", but the test
was mocking / spying on "unzip", this fixes the test to mock/spy on
the method actually used, patterned after the android studio test
Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Thank you!

@thymikee thymikee merged commit 9def6fe into react-native-community:master Feb 10, 2022
@mikehardy mikehardy deleted the fix-jdk-windows-doctor-test branch February 10, 2022 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants