fix: Test command runs tests twice and often fails on Android #3786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With the new LiveSync with sockets functionality, the
tns test android
command executes the tests twice and often exits with a non-zero exit code. The problem is that the command uses the LiveSync logic to upload the files first, restart the application after that and runs the tests. However, the new LiveSync requires the application to be running on device in order to have a socket for file transfer. When we start the application in order to execute the LiveSync, the tests are run. During the run the LiveSync may end and CLI will restart the app. If this happens during running the tests, Karma will mark them as failure and the next execution may not be triggered.Fix this by creating a temp file on device before starting the LiveSync operation. Runtime will check if the file exists and if it does, it will sleep the application for 30 seconds, i.e. it will not load the JS implementation of the app. During this time CLI will transfer all files, remove the temp file from device and restart the application. Runtime will not find the file and it will load the application.
fix: LiveSync to Android hangs for 30 seconds
When LiveSync operation is executed, CLI tries to connect to device socket for 30 seconds. In case it succeeds, the timer is not stopped and this keeps the process alive for 30 seconds.
PR Checklist
What is the current behavior?
tns test android --justlaunch
executes tests twice, often fails and in many cases does not release the terminal.What is the new behavior?
tns test android --justlaunch
executes tests only once and exits the process immediately after finishing the execution.