-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Jest runner with Wdio runner E2E #41218
base: main
Are you sure you want to change the base?
Conversation
Hi @Othinn! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Base commit: 96ed119 |
elementIsFound = await driver.$(locator).isDisplayed(); | ||
while (!elementIsFound) { | ||
elementIsFound = await $(locator).isDisplayed(); | ||
while (!(await elementIsFound)) { | ||
driver.touchPerform([ | ||
{ | ||
action: 'press', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest changing this scroll logic completely. Taking the window size and performing mathematical operations on it to determine touches is prone to error. Here's a better way:
await browser.waitUntil(
async () => {
await driver.execute('mobile: scroll', { direction: 'down' });
return await $(locator).isDisplayed();
},
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to change scroll logic with your or similar solutions, but after testing, the current implementation is less flak, at least in the local environment.
|
|
||
const cancelText = 'Your application has been cancelled!'; | ||
|
||
describe('Test is checking cancel button', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (optional recommendation, up to you): describe()
should explain the feature as a whole being tested. Thinking about it from improving the debugging experience, I think the description should be:
"Testing Cancel Button Functionality"
This tells the engineer exactly which feature is under test.
const cancelText = 'Your application has been cancelled!'; | ||
|
||
describe('Test is checking cancel button', function () { | ||
it('Should view properly submit cancel text', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Improve test name. An engineer debugging this should know exactly what the test does by reading the name. After reading this, I'm not sure what this test is doing - I have to read the code to figure that out.
An example of a better name:
"Press Cancel Button - Validate {Correct Action}" but replace the {} with what you expect to happen
describe('Test is checking cancel button', function () { | ||
it('Should view properly submit cancel text', async function () { | ||
expect( | ||
await ComponentsScreen.checkButtonComponentIsDisplayed(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this should be in a before hook? Or it's own test? It looks like this is handling setting up the app to get the correct state, which doesn't correlate to the test name.
Making sure each test is has a defined function is important for debugging purposes (and code readability).
Rather than having the following structure:
it("Testing cancel button")
// Setup app
// Test Cancel Button
We can organize as:
it('Setup Cancel Button Testing')
// Setup app to test cancel button
it('Test cancel button')
// Test cancel button
@@ -171,6 +171,8 @@ jobs: | |||
(yarn test-e2e-ios 2>&1 | tee /tmp/test_log) || true | |||
- store_artifacts: | |||
path: /tmp/test_log | |||
- store_artifacts: | |||
path: ~/react-native/packages/rn-tester-e2e/reports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also include the error screenshots here. That way, the engineer can see a screenshot of the failure.
}); | ||
|
||
it('Should click on the Activity Indicator component', async () => { | ||
await ComponentsScreen.clickActivityIndicatorComponent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every test should have an assert (or else, what is it doing?).
Does this test have a purpose?
context, | ||
{error, result, duration, passed, retries}, | ||
) { | ||
if (!passed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (Optional):
Before checking if the test passed, I added a small snippet of code that I found useful when debugging through logs. It can give you a quick method of searching for the results of a specific test in a long log file:
const resultString = results.passed ? 'Passed' : 'Failed';
console.log(``\nTest Case: "${test.description}".\nResult: "${resultString}".\nDuration: "${(results.duration/600).toFixed(2)}s". \n``);
type PlatformsReference = { | ||
ios: string, | ||
android: string, | ||
}; | ||
|
||
class Utils { | ||
async checkElementExistence(locator: string): Promise<boolean> { | ||
await driver.$(locator).waitForDisplayed(); | ||
return driver.$(locator).isDisplayed(); | ||
await $(locator).waitForDisplayed(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: In all these helper methods, I suggest utilizing the errorMsg
parameter in waitForDisplayed()
. You can pass in the specific locator string so the error message is specific. If not, it will be confusing when debugging to see where it failed and which component.
For example,
await $(locator).waitForDisplayed({ timeout: 15000, timeoutMsg: "The element with locator=" + locator + " was not found"});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It helps debugging a ton
await driver.$(locator).waitForDisplayed(); | ||
return driver.$(locator).isDisplayed(); | ||
await $(locator).waitForDisplayed(); | ||
return $(locator).isDisplayed(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just return await $(locator).waitForDisplayed();
. Such as return await $(locator).waitForDisplayed();
.
waitForDisplayed throws an error if it fails, or returns true if it succeeds. Adding return $(locator).isDisplayed();
is unnecessary and will decrease perf by adding another API call.
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
@Othinn any chance you could rebase that to main and migrate to GitHub Actions? |
Summary:
Due to the high flakiness of e2e tests, we suggested changing the Jest runner to Wdio runner, which should help us reduce the flakiness and increase the usefulness of the tests through better logs.
Changelog:
test
block to Mochasit
and changed the arrow functions to regular functions (in Mocha, the arrow function is discouraged from using https://mochajs.org/#arrow-functions)it
for better visibility on resultsspec
reporter. After we decide about result storing, we can change to, eg. AllureTest Plan: