Move e2etest pages into rntester#5555
Conversation
| "HorizontalAlignment": "Stretch", | ||
| "Margin": "0,0,0,0", | ||
| "RenderSize": [800, 360], | ||
| "RenderSize": [759, 360], |
There was a problem hiding this comment.
759 [](start = 17, length = 3)
These smaller widths are expected. RNTester has a container component that has margins on it, and this pages stretches across the entire available space, which is now smaller. #Resolved
There was a problem hiding this comment.
the e2etest app had some code on startup which set the window size to 800x600 I believe, to ensure we get a consistent size. We should do that here too, otherwise the masters may not match if people ever resize/maximize etc #Resolved
There was a problem hiding this comment.
That code in the app side is still there. Also the tree dumper control has code to resize to 800x600.
In reply to: 457682484 [](ancestors = 457682484)
| "strict": true, | ||
| "rootDir": "." | ||
| "rootDir": ".", | ||
| "esModuleInterop": true |
There was a problem hiding this comment.
This could be breaking for code relying on previous esModule CommonJS interop behavior (e.g. import * is not callable with this enabled). What led to the need for the change and is it possible to change imports/exports to get the same effect? Note that TS has some special syntax for CommonJS interop as well.
The rest of the packages in the repo have this turned off, so having consistent behavior would be nice. #Pending
There was a problem hiding this comment.
All the tests were originally authored over in packages\e2etest with this turned on. So for example this line of code in AccessibilityTestPage.tsx won't compile without it turned on:
import React, { useState } from 'react'; => error TS1259: Module '"D:/rnw/node_modules/@types/react/index"' can only be default-imported using the 'esModuleInterop' flag
I honestly don't understand the error so I went the easy route and turned the option on. I'm happy to change the import if only I could understand, it's quite bizarre!
In reply to: 457675352 [](ancestors = 457675352)
There was a problem hiding this comment.
Reading this article over: https://itnext.io/great-import-schism-typescript-confusion-around-imports-explained-d512fc6769c2
The author recommends turning this option on: "...So I really advocate the usage of esModuleInterop option, cause it not only allows you to write less code, easier to read and spec-complaint code (and it's not just ranting, rollup for example won't allow you to use star imports in such way), but also mitigates some friction between typescript and babel communities."
In reply to: 457727708 [](ancestors = 457727708,457675352)
There was a problem hiding this comment.
Yeah, Babel having it on by default and Typescript having it off by default is annoying. I'd kind of rather we have it off everywhere or on everywhere personally, and the risk of runtime issues makes me hesitant to turn it on anywhere where it used to be off.
The root cause of the issue is that CommonJS is still used internally for React, and Node, but ES6 modules added default imports which don't really have a commonJS equivalent. The interop setting sort of changes how Typescript or Babel projects a default import. My own preference has been to just avoid default import/export with anything interfacing with CommonJS since behavior is settings dependent.
I think the non esModuleInterop way to do this would be to have "import * as React from 'react'" on its own line instead of the default import. #Resolved
There was a problem hiding this comment.
Thanks for the tip. I turned the option off and fixed up all the imports to do it the "non-esModuleInterop" way. Would love to read an article that actually explains all of this, I feel like I came to the party after everyone else already is in the club, leaving me feeling rather clueless.
In reply to: 457742505 [](ancestors = 457742505)
There was a problem hiding this comment.
I think the historical context of being used to CommonJS before ES6 helps. Finding an article explaining CommonJS, then looking at the ES6 article on MDN should give some context on the different models, and why default imports (or setting module.exports to a single function) are wonky.
The basic idea is that CommonJS modules export a single value. This is often an object that's an aggregate of exports, which maps directly to most of ES6, but ES6 default imports don't really have a CommonJS equivalent. Without esModuleInterop, a default import will look for the ".default" property of the CommonJS export, and agregate imports are callable, since CommonJS allows exporting single functions.
With interop on, idefault imports will import the entire aggregate object IIRC, and calling a CommonJS export requires doing a default import instead of importing all.
|
|
||
| beforeAll(() => { | ||
| HomePage.backToHomePage(); | ||
| // HomePage.backToHomePage(); |
There was a problem hiding this comment.
Could we leave a comment about why this is commented out? #Resolved
There was a problem hiding this comment.
Thanks for the reminder. This code will never be necessary so I just removed it from all the tests.
In reply to: 457675832 [](ancestors = 457675832)
| }, | ||
| { | ||
| "type": "platform", | ||
| "file": "src/RNTester/js/examples-win/LegacyTests/AccessibilityTestPage.tsx" |
There was a problem hiding this comment.
If you want, you could also add "examples-win" to the list of unenforced directories at the top of the file and remove the overrides listed for it. Nothing in that directory should need three-way-merge, so it seems safe. #Resolved
There was a problem hiding this comment.
|
Hello @kmelmon! Because this pull request has the 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 (
|
… test already launches the app
…on. Reordering items.
…e-launching the test app. Trying --no-launch option
* first batch of changes * Change files * lint * fix test failures, all due to margin within RNTester * move (?) files * refactor consts * remove unused strings * remove unreliable test * increase app launch wait, removed unnecessary code * exclude examples-win * turn off esModuleInterop * lint fix * experimenting with sleep before test starts * troubleshooting instability with first test: try --no-launch param as test already launches the app * test instability continued: issue may be due to FlatList virtualization. Reordering items. * revert --no-launch, this is unrelated * it looks like the first test reliability issue is caused by killing/re-launching the test app. Trying --no-launch option
Summary: This change adds a testID to each item in the RNTester list. This helps Appium find items in the list for automated tests. The change was added in react-native-windows as part of end-to-end test infrastructure changes. See microsoft/react-native-windows#5555 We'd like to remove this forked file, upstreaming this change will enable us to do that. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [General] [Changed] - add testID to items in RNTester test list, helps test automation tools find the items Pull Request resolved: #30138 Test Plan: Change is currently running in react-native-windows CI loop. Reviewed By: cpojer Differential Revision: D24434352 Pulled By: appden fbshipit-source-id: 998916d8fe4e4e4cd6ac764baabb9fd5f2e312c7
Fixes #5484
This change prepares us to use RNTester as the primary app for end-to-end UI integration tests. Currently we use our own app inside E2ETest. This will limit us as we'd need to create test pages from scratch. We already have a lot of potential test coverage with RNTester, and we can add whatever pages we want to it as well, so let's use RNTester instead.
This change moves the 6 existing test pages over to RNTester and makes the necessary changes to the test app to load RNTester instead of the current app.
Microsoft Reviewers: Open in CodeFlow