-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to launch android emulator and run in-app tests
- Loading branch information
Showing
7 changed files
with
178 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const http = require('http'); | ||
|
||
async function pollInAppServer() { | ||
const startTime = Date.now(); | ||
const maxDuration = 5 * 60 * 1000; // 5 minutes | ||
const pollInterval = 1000; // 1 second | ||
|
||
while (Date.now() - startTime < maxDuration) { | ||
try { | ||
const response = await makeHttpRequest( | ||
'http://localhost:3000/test_results' | ||
); | ||
if (response !== null) { | ||
let parsed_response = JSON.parse(response); | ||
const allTestsPassed = parsed_response.results.reduce((acc, r) => { | ||
return acc && r.type !== 'incorrect'; | ||
}, true); | ||
|
||
if (allTestsPassed) { | ||
console.log('🟢🟢🟢🟢🟢 All tests passed!'); | ||
process.exit(0); | ||
} else { | ||
console.log('Some tests failed'); | ||
process.exit(1); | ||
} | ||
} | ||
} catch (error) { | ||
console.error('Error occurred during polling:', error); | ||
} | ||
|
||
await new Promise((resolve) => setTimeout(resolve, pollInterval)); | ||
} | ||
|
||
console.error('Polling failed after 5 minutes'); | ||
process.exit(1); | ||
} | ||
|
||
function makeHttpRequest(url) { | ||
return new Promise((resolve, reject) => { | ||
http | ||
.get(url, (res) => { | ||
let data = ''; | ||
|
||
res.on('data', (chunk) => { | ||
data += chunk; | ||
}); | ||
|
||
res.on('end', () => { | ||
resolve(data); | ||
}); | ||
}) | ||
.on('error', (error) => { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
|
||
pollInAppServer(); |
Oops, something went wrong.