Skip to content

Conversation

@thib92
Copy link
Contributor

@thib92 thib92 commented Sep 23, 2019

Summary:

Add unit tests for the healthchecks for androidSDK and androidNDK

Also removed a $FlowFixMe that wasn't removed when the androidSDK file was moved to TS.

Related to #694

Test Plan:

CI is green

@thib92
Copy link
Contributor Author

thib92 commented Sep 23, 2019

@lucasbento tests are failing on Windows because apparently the androidSDK check specific to Windows is not responding within 5s.

I'm not too sure why but I'm suspecting the execa call here is not responding. Should we put a timeout on it?

const {stdout} = await execa(
process.env.ANDROID_HOME
? `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`
: 'sdkmanager',
['--list'],
);

@lucasbento
Copy link
Member

@thib92: I would say so, it seems like a command that can take quite a while to respond.

I'm not sure if 5 seconds would be sufficient though, @thymikee can you tell us about that?

I didn't actually do this piece of code so I am not sure about it.

@thymikee
Copy link
Member

I'd mock a response that we expect, no time for long timeouts.

@lucasbento
Copy link
Member

Yes, that's definitely a better approach 😄

Copy link
Member

@lucasbento lucasbento left a comment

Choose a reason for hiding this comment

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

Just a few comments, good work as always 🙂

@thib92
Copy link
Contributor Author

thib92 commented Sep 24, 2019

@lucasbento thanks for the good review. Everything should be fixed.

Copy link
Member

@lucasbento lucasbento left a comment

Choose a reason for hiding this comment

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

Awesome, thanks @thib92!

@thib92
Copy link
Contributor Author

thib92 commented Sep 24, 2019

Btw I'm doing a lot of copy-paste between all the healthcheck tests. Once I'm done with all of them, I'll see if I can create util functions to avoid repeating code in the tests.

@lucasbento
Copy link
Member

lucasbento commented Oct 8, 2019

@thymikee: can you please give a review?

const logSpy = jest.spyOn(common, 'logManualInstallation');

const mockExeca = (stdout: string) => {
jest.mock('execa', () => jest.fn());
Copy link
Member

@thymikee thymikee Oct 8, 2019

Choose a reason for hiding this comment

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

jest.mock is hosited to the top of the parent scope, it's not meant to be called mutliple times. Can you move it to the top-level scope, right after imports, so it's a bit more obvious the execa module is mocked?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it a little bit to be easier to understand and more standard. What do you think?


const logSpy = jest.spyOn(common, 'logManualInstallation');

const mockExeca = (stdout: string) => {
Copy link
Member

Choose a reason for hiding this comment

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

Let's rename it to mockSdkManagerResponse or something so that it's closer to what it's actually doing, since we don't extract execa call to a function we could mock – which would make it obvious what is mocked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See what I changed. What do you think?

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.

LGTM, small things to adjust

@thymikee thymikee merged commit 2961bf0 into react-native-community:master Oct 14, 2019
@thib92 thib92 deleted the tests-healthcheck branch October 14, 2019 09:01
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.

3 participants