Closed nmanhit closed 1 year ago
- We have edited the Jest configuration here https://github.com/kintone-labs/kintone-cli/pull/112/files#diff-1e058ca1442e46581b13571fb8d261f9e1f5657e26c96634d4c1072f0f0347f1R10-R54
Thank you for updating!
But still, there are some commands that don't reach the goal even though the test command passed. Please double check it.
I thought the link isn't relevant to the theme. But I confirmed that there are no unnecessary import lines anymore.
- There are some commands that have validator test cases and do not have them. Please unify it.
How about this?
- There are some commands that have validator test cases and do not have them. Please unify it.
How about this?
I changed the "validator" file name to the name that is suitable for test cases. I updated the solutions in here: https://github.com/kintone-labs/kintone-cli/pull/112/files/640895fb1f0b2fdb9eb0cc4a8148252b6ce5db6d..01992b87833e7d379cd354d15fb8e02012f676cd
Please have a look! Thank you!
I changed the "validator" file name to the name that is suitable for test cases. I updated the solutions in here: https://github.com/kintone-labs/kintone-cli/pull/112/files/640895fb1f0b2fdb9eb0cc4a8148252b6ce5db6d..01992b87833e7d379cd354d15fb8e02012f676cd
Please have a look! Thank you!
Sorry, could you please tell me the exact files you changed for this? The above file changes might include other than the validator-related ones.
Sorry, could you please tell me the exact files you changed for this? The above file changes might include other than the validator-related ones.
The detail is: Initialize/test/validator.test.ts is divided into:
Lint/test/validator.test.ts is changed to:
The detail is: Initialize/test/validator.test.ts is divided into:
- Initialize/test/scope.test.ts
- Initialize/test/preset.test.ts
- Add code to Initialize/test/appType.test.ts
In the preset.test.ts file, there is only an invalid preset test case. Don't we need a valid preset test case?
Lint/test/validator.test.ts is changed to:
- Lint/test/fixOption.test.ts
Ok!
For other commands... It seems there is no test case for Build/validator.ts, Deploy/validator.ts, Dev_validator.ts. Please check it.
About Dev command, the coverage is low. Could you please double-check it. If it's difficult to improve it, please tell me.
And I'm confused that the test passed even though the coverage doesn't meet the goal. Why is this happening?
When executing test, this two errors occurred. Will the same error occur on your environment?
About this Japanese part, it is "Error occurred. Failed to login to kintone. Please check the base URL." エラーが発生しました kintoneへのログインに失敗しました。ベースURLを確認してください。
In the preset.test.ts file, there is only an invalid preset test case. Don't we need a valid preset test case?
We don't need a valid preset test because:
For other commands... It seems there is no test case for Build/validator.ts, Deploy/validator.ts, Dev_validator.ts. Please check it.
The test case for validators in commands is placed in the right contexts, for example:
About Dev command, the coverage is low.
Currently, I can't find a way to improve it, it is stuck with --watch, and other javascript events. Sorry for the inconvenience.
And I'm confused that the test passed even though the coverage doesn't meet the goal. Why is this happening?
The coverage of Dev command does not pass, this has little effect on the whole coverage
The test passed because the total coverage is more than 85%
When executing test, this two errors occurred. Will the same error occur on your environment?
Because we test on the local environment, we can't log in with it. It will have some errors when the code has actions that interact with the kintone environment
We don't need a valid preset test because:
- When passing a valid preset, the action next is to test for the scope case
- Don't have code for valid preset
I got it! If so, there's no problem with it. Thanks for the confirmation.
The test case for validators in commands is placed in the right contexts, for example:
- In validator of Build has function that checks the app name
- So we put the test case to appName.test.ts
- Similar to another command
The reason for changing this behavior is:
- When the validator file has too many cases for testing, the validator test file will have too much code for testing, this is hard to read, maintain, and improve. I think we discussed it here: https://bozuman.cybozu.com/k/23175/show#record=3283&comment=72
Yes, I understand the discussion. I know you basically developed validator-related function test cases in each separate option test file. But I couldn't find the exact test case for Build/validator.ts, Deploy/validator.ts, Dev_validator.ts functions. For example, when there is no appName, program will return 'App name missing', but there is no test case for it. I found this because you developed a similar test case here. https://github.com/kintone-labs/kintone-cli/commit/52c99839f7d87a67c5ba9b082b68abb38b93c0bc#diff-e0073e61c60ec0ba6020821f942dcabe5b6f151e029ec3509649df190576f541
The coverage of Dev command does not pass, this has little effect on the whole coverage
- But if we have two or three commands that do not pass, the coverage will slow.
The test passed because the total coverage is more than 85%
That's why! Sorry for my lack of knowledge. I understand it now and it's ok.
Because we test on the local environment, we can't log in with it. It will have some errors when the code has actions that interact with the kintone environment
I see... When executing on CI, will it work fine with no error because it has an environment variable for login??
Yes, I understand the discussion. I know you basically developed validator-related function test cases in each separate option test file. But I couldn't find the exact test case for Build/validator.ts, Deploy/validator.ts, Dev_validator.ts functions. For example, when there is no appName, program will return 'App name missing', but there is no test case for it. I found this because you developed a similar test case here.
With Buid, Deploy, Dev commands, I write test cases for functions in the validator by calling the main function In that main function, there are call functions of validator: validator.devValidator(cmd), with that, the jest will cover the code of functions in the validator. For example with dev command:
I think it makes sense for the validator of each command, if you want to add test for validator like the Lint command, I will update the code
I will list the test code for the validator of each command below:
Build/validator.ts: https://github.com/kintone-labs/kintone-cli/pull/112/files#diff-15e0d5541645c5643f38210ba7644c149b1fcf8f252494389438b600b3606912
Deploy/validator.ts: https://github.com/kintone-labs/kintone-cli/pull/112/files#diff-4575bf6cd7082170f1c7f3c7527649995c9e97d847198a0a485ad1fef8781800
Dev_validator.ts: https://github.com/kintone-labs/kintone-cli/pull/112/files#diff-c98746713f418eaf668a56a275f7425c134d2d4819fcf5963a2280c0b35dc80c
I see... When executing on CI, will it work fine with no error because it has an environment variable for login??
It will have errors when executing on CI, but it does not affect CI because our jest does not handle that case.
You can see detail in here: https://github.com/kintone-labs/kintone-cli/actions/runs/5971290256/job/16200124838
I think it makes sense for the validator of each command, if you want to add test for validator like the Lint command, I will update the code
Thanks for understanding my thoughts. You have already achieved the coverage, so it's not a necessary item, but it would be great if you could add the test cases because we recognize it now!
It will have errors when executing on CI, but it does not affect CI because our jest does not handle that case.
I got it. Let's skip the error output because it's not directly related to the testing behavior.
Thanks for understanding my thoughts. You have already achieved the coverage, so it's not a necessary item, but it would be great if you could add the test cases because we recognize it now!
I updated code for the validator here: https://github.com/kintone-labs/kintone-cli/pull/112/commits/5c5c805f31466ac8ccfdd9e57b8e747728ae4d52
We have edited the Jest configuration here https://github.com/kintone-labs/kintone-cli/pull/112/files#diff-1e058ca1442e46581b13571fb8d261f9e1f5657e26c96634d4c1072f0f0347f1R10-R54 When I read the Jest documentation, I thought that configuring it as
ref: https://jestjs.io/docs/configuration#coveragethreshold-object However, it doesn't work with that configuration.
we have removed https://github.com/kintone-labs/kintone-cli/pull/112/commits/dca2c0759e43f67a11fcb4eb06d2b728177a58eb