Skip to content
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

Support e2e test - webdriverio #2975

Merged
3 commits merged into from
Aug 29, 2019
Merged

Support e2e test - webdriverio #2975

3 commits merged into from
Aug 29, 2019

Conversation

licanhua
Copy link
Contributor

@licanhua licanhua commented Aug 22, 2019

Fix #2135

This PR is using mocha + WebDriverIO.

Another option is using Jest+selenium-webdriver, which is described in selenium-appium.
Please refer to Examples of selenium-webdriver to see the difference of the two project.

Have problem to merge #2928 with master, so I create a new pullrequest.
This pullrequest use webdriverio other than selenium-webdriver.
Provides test infrasture for e2e testing.
Test infrasture requirements:

  1. intellisense and typescript when authoring test case. Verified with vs code
  2. simplify the process for test authoring. PageObjects are introduced
  • - wdio <-> testcase <> webdriverio lib <-> WinAppDriver <-> ReactUWPTestApp

  • test running: wdio

  • test libraries: webdriverio

  • test driver on windows: WinAppDriver

  • testapp: ReactUWPTestApp

  • - ReactUWPTestApp

  • Two level structure. Provides MainPage and ReactTestPage. MainPage is pure Xaml, and ReactTestPage loads RN page. TestInventory helps setup the relationship from the button in mainpage to what JS bundle would be loaded and what automationid would expose to test case.
    image
    image

  • - e2e test organization
    A. RN testapp like TextInputTestPage is in ReactUWPTestApp
    B. js test library and pageobjects is in e2e/testlib
    C. testcases are in e2e/tests

Recommendations to write tests

  1. Add/update RNWindows test pages with testId to ReactUWPTestApp
    which will be finally bundled and launched by the testapp
  2. add/update matched pageojects in e2e/testlib/pages which provides locator to testId in ReactUWPTestApp
  3. Add functions in e2e/testlib/pages/HomePage if needed.
    54 Add/Update test case in e2e/tests.

How to run the test case:

  1. build and deploy ReactUWPTestApp
  2. cd e2e and yarn install
  3. install winappdriver 1.? . (note: New WinAppDriver is not ready yet. WebDriverIO have problem to integrate with WinAppDriver which is described in Make WebdriverIO to support native app testing on Windows with WinAppDriver webdriverio/webdriverio#4369. I created a PR on WinAppDriver but it's still in the release process)
  4. start appium by 'npm run appium'
  5. 'npm run test' to run the test.

document update and test pipeline setup is not in the scope.

Microsoft Reviewers: Open in CodeFlow

@licanhua licanhua requested a review from a team as a code owner August 22, 2019 05:54
@ghost ghost added the vnext label Aug 22, 2019
vnext/ReactWindows-UWP.sln Outdated Show resolved Hide resolved
@kmelmon
Copy link
Contributor

kmelmon commented Aug 23, 2019

Following-up on previous PR: Why is e2e a separate package? Shouldn't those just be devDependencies of react-native-windows?
Then you wouldn't have another yarn install step.
#Closed


Refers to: vnext/e2e/package.json:33 in b478643. [](commit_id = b478643, deletion_comment = False)

@kmelmon
Copy link
Contributor

kmelmon commented Aug 23, 2019

Not needed. #Closed


Refers to: vnext/ReactUWPTestApp/ReactTestPage.xaml.cs:114 in b478643. [](commit_id = b478643, deletion_comment = False)

@licanhua
Copy link
Contributor Author

I would defer it because:

  1. It's possible package the whole e2e directory includes node_modules and deploy it to remote machine in the future.
  2. No matter selenium-webdriver or webdriverio, there are conflicts on tsconfig.json.
    For example, WebDriverIO expect esModuleInterop to be true when loading modules, also it run a lot of error like:
    [0-1] 2019-08-26T22:33:50.638Z ERROR @wdio/runner: TypeError: e2e\test\testInput.spec.ts: Emit skipped
    at getOutput (D:\repo\react-native-windows\node_modules\ts-node\src\index.ts:370:15)
    at Object.compile (D:\repo\react-native-windows\node_modules\ts-node\src\index.ts:558:11)
    at Module.m._compile (D:\repo\react-native-windows\node_modules\ts-node\src\index.ts:439:43)
    at Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Object.require.extensions.(anonymous function) [as .ts] (D:\repo\react-native-windows\node_modules\ts-node\src\index.ts:442:12)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    0-1 worker error { name: 'TypeError',

In reply to: 524431584 [](ancestors = 524431584)


Refers to: vnext/e2e/package.json:33 in b478643. [](commit_id = b478643, deletion_comment = False)

@licanhua licanhua changed the title Support e2e test - new Support e2e test - webdriverio Aug 26, 2019
@kmelmon
Copy link
Contributor

kmelmon commented Aug 26, 2019

OK let's not change this for now.


In reply to: 525061424 [](ancestors = 525061424,524431584)


Refers to: vnext/e2e/package.json:33 in b478643. [](commit_id = b478643, deletion_comment = False)

Copy link
Contributor

@kmelmon kmelmon left a comment

Choose a reason for hiding this comment

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

:shipit:

@licanhua
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@licanhua licanhua added the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label Aug 28, 2019
@ghost
Copy link

ghost commented Aug 28, 2019

Hello @licanhua!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 0f7a923 into microsoft:master Aug 29, 2019
@licanhua licanhua deleted the e2e branch August 29, 2019 01:22
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Infrastructure] Setup test infrastructure
2 participants