facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.7k stars 24.29k forks source link

Tests moved from Libraries to src/private are now being published in the NPM package #43242

Closed jonthysell closed 7 months ago

jonthysell commented 7 months ago

Description

It looks like some part of the NPM publish process filters out the __tests__ folders within react-native/Libraries from being published. It's not filtered in the package.json AFAIK, so maybe in some script?

Anyway, when moving files to src/private (particularly in src/private/webapis/dom/oldstylecollections/ ) that filtering is no longer being applied, so those test files are now being published.

This probably isn't a problem for most, but downstream in react-native-windows this breaks our validation as flow checks fail for those files. We're trying to catch up so we can publish 0.74. We're hitting the issue here, integrating to 0.74.0-nightly-20240122-4e92f87df in this PR: https://github.com/microsoft/react-native-windows/pull/12761

Example:

Error ------------------------------------ src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:139:39

Cannot get `collection[i]` because property `0` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:139:39
   139|         expect(value).toBe(collection[i]);
                                              ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Steps to reproduce

  1. Look at react-native NPM package >= 0.74.0-nightly-20240122-4e92f87df.
  2. See that there are tests folders that shouldn't be there

React Native Version

0.74.0.rc.1

Affected Platforms

Build - Windows

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: Windows 11 10.0.26063
  CPU: "(24) x64 AMD Ryzen Threadripper PRO 3945WX 12-Cores     "
  Memory: 48.67 GB / 63.86 GB
Binaries:
  Node:
    version: 18.17.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.19
    path: C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm:
    version: 9.6.2
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    AllowAllTrustedApps: Enabled
    Versions:
      - 10.0.18362.0
      - 10.0.19041.0
      - 10.0.22000.0
      - 10.0.22621.0
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 16.11.34601.136 (Visual Studio Enterprise 2019)
    - 17.9.34616.47 (Visual Studio Enterprise 2022)
Languages:
  Java: Not Found
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

Error ---------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:23:23

Cannot get `collection[0]` because property `0` is missing in `DOMRectList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:23:23
   23|     expect(collection[0]).toBe(domRectA);
                             ^

References:
   src/private/webapis/dom/oldstylecollections/DOMRectList.js:74:4
   74| ): DOMRectList {
          ^^^^^^^^^^^ [1]

Error ---------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:24:23

Cannot get `collection[1]` because property `1` is missing in `DOMRectList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:24:23
   24|     expect(collection[1]).toBe(domRectB);
                             ^

References:
   src/private/webapis/dom/oldstylecollections/DOMRectList.js:74:4
   74| ): DOMRectList {
          ^^^^^^^^^^^ [1]

Error ---------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:25:23

Cannot get `collection[2]` because property `2` is missing in `DOMRectList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:25:23
   25|     expect(collection[2]).toBe(domRectC);
                             ^

References:
   src/private/webapis/dom/oldstylecollections/DOMRectList.js:74:4
   74| ): DOMRectList {
          ^^^^^^^^^^^ [1]

Error ---------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:26:23

Cannot get `collection[3]` because property `3` is missing in `DOMRectList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:26:23
   26|     expect(collection[3]).toBe(undefined);
                             ^

References:
   src/private/webapis/dom/oldstylecollections/DOMRectList.js:74:4
   74| ): DOMRectList {
          ^^^^^^^^^^^ [1]

Error ---------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:33:16

Cannot assign `new DOMRectReadOnly()` to `collection[0]` because property `0` is missing in `DOMRectList` [1].
[prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:33:16
   33|     collection[0] = new DOMRectReadOnly();
                      ^

References:
   src/private/webapis/dom/oldstylecollections/DOMRectList.js:74:4
   74| ): DOMRectList {
          ^^^^^^^^^^^ [1]

Error ---------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:47:18

Cannot assign `new DOMRectReadOnly()` to `collection[0]` because property `0` is missing in `DOMRectList` [1].
[prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:47:18
   47|       collection[0] = new DOMRectReadOnly();
                        ^

References:
   src/private/webapis/dom/oldstylecollections/DOMRectList.js:74:4
   74| ): DOMRectList {
          ^^^^^^^^^^^ [1]

Error ---------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:49:23

Cannot get `collection[0]` because property `0` is missing in `DOMRectList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:49:23
   49|     expect(collection[0]).toBe(domRectA);
                             ^

References:
   src/private/webapis/dom/oldstylecollections/DOMRectList.js:74:4
   74| ): DOMRectList {
          ^^^^^^^^^^^ [1]

Error ---------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:70:37

Cannot get `collection[i]` because property `0` is missing in `DOMRectList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js:70:37
   70|       expect(value).toBe(collection[i]);
                                           ^

References:
   src/private/webapis/dom/oldstylecollections/DOMRectList.js:74:4
   74| ): DOMRectList {
          ^^^^^^^^^^^ [1]

Error ------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:18:23

Cannot get `collection[0]` because property `0` is missing in `HTMLCollection` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:18:23
   18|     expect(collection[0]).toBe('a');
                             ^

References:
   src/private/webapis/dom/oldstylecollections/HTMLCollection.js:80:4
   80| ): HTMLCollection<T> {
          ^^^^^^^^^^^^^^^^^ [1]

Error ------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:19:23

Cannot get `collection[1]` because property `1` is missing in `HTMLCollection` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:19:23
   19|     expect(collection[1]).toBe('b');
                             ^

References:
   src/private/webapis/dom/oldstylecollections/HTMLCollection.js:80:4
   80| ): HTMLCollection<T> {
          ^^^^^^^^^^^^^^^^^ [1]

Error ------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:20:23

Cannot get `collection[2]` because property `2` is missing in `HTMLCollection` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:20:23
   20|     expect(collection[2]).toBe('c');
                             ^

References:
   src/private/webapis/dom/oldstylecollections/HTMLCollection.js:80:4
   80| ): HTMLCollection<T> {
          ^^^^^^^^^^^^^^^^^ [1]

Error ------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:21:23

Cannot get `collection[3]` because property `3` is missing in `HTMLCollection` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:21:23
   21|     expect(collection[3]).toBe(undefined);
                             ^

References:
   src/private/webapis/dom/oldstylecollections/HTMLCollection.js:80:4
   80| ): HTMLCollection<T> {
          ^^^^^^^^^^^^^^^^^ [1]

Error ------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:28:16

Cannot assign `'replacement'` to `collection[0]` because property `0` is missing in `HTMLCollection` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:28:16
   28|     collection[0] = 'replacement';
                      ^

References:
   src/private/webapis/dom/oldstylecollections/HTMLCollection.js:80:4
   80| ): HTMLCollection<T> {
          ^^^^^^^^^^^^^^^^^ [1]

Error ------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:42:18

Cannot assign `'replacement'` to `collection[0]` because property `0` is missing in `HTMLCollection` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:42:18
   42|       collection[0] = 'replacement';
                        ^

References:
   src/private/webapis/dom/oldstylecollections/HTMLCollection.js:80:4
   80| ): HTMLCollection<T> {
          ^^^^^^^^^^^^^^^^^ [1]

Error ------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:44:23

Cannot get `collection[0]` because property `0` is missing in `HTMLCollection` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:44:23
   44|     expect(collection[0]).toBe('a');
                             ^

References:
   src/private/webapis/dom/oldstylecollections/HTMLCollection.js:80:4
   80| ): HTMLCollection<T> {
          ^^^^^^^^^^^^^^^^^ [1]

Error ------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:65:37

Cannot get `collection[i]` because property `0` is missing in `HTMLCollection` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js:65:37
   65|       expect(value).toBe(collection[i]);
                                           ^

References:
   src/private/webapis/dom/oldstylecollections/HTMLCollection.js:80:4
   80| ): HTMLCollection<T> {
          ^^^^^^^^^^^^^^^^^ [1]

Error ------------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:18:23

Cannot get `collection[0]` because property `0` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:18:23
    18|     expect(collection[0]).toBe('a');
                              ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Error ------------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:19:23

Cannot get `collection[1]` because property `1` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:19:23
    19|     expect(collection[1]).toBe('b');
                              ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Error ------------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:20:23

Cannot get `collection[2]` because property `2` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:20:23
    20|     expect(collection[2]).toBe('c');
                              ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Error ------------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:21:23

Cannot get `collection[3]` because property `3` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:21:23
    21|     expect(collection[3]).toBe(undefined);
                              ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Error ------------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:37:16

Cannot assign `'replacement'` to `collection[0]` because property `0` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:37:16
    37|     collection[0] = 'replacement';
                       ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Error ------------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:51:18

Cannot assign `'replacement'` to `collection[0]` because property `0` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:51:18
    51|       collection[0] = 'replacement';
                         ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Error ------------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:53:23

Cannot get `collection[0]` because property `0` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:53:23
    53|     expect(collection[0]).toBe('a');
                              ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Error ------------------------------------- src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:74:37

Cannot get `collection[i]` because property `0` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:74:37
    74|       expect(value).toBe(collection[i]);
                                            ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Error ------------------------------------ src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:109:39

Cannot get `collection[i]` because property `0` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:109:39
   109|         expect(value).toBe(collection[i]);
                                              ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Error ------------------------------------ src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:127:46

Cannot get `collection[i]` because property `0` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:127:46
   127|         expect(entry).toEqual([i, collection[i]]);
                                                     ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Error ------------------------------------ src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:139:39

Cannot get `collection[i]` because property `0` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:139:39
   139|         expect(value).toBe(collection[i]);
                                              ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Error ------------------------------------ src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:153:39

Cannot get `collection[i]` because property `0` is missing in `NodeList` [1]. [prop-missing]

   src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js:153:39
   153|         expect(value).toBe(collection[i]);
                                              ^

References:
   src/private/webapis/dom/oldstylecollections/NodeList.js:102:65
   102| export function createNodeList<T>(elements: $ReadOnlyArray<T>): NodeList<T> {
                                                                        ^^^^^^^^^^^ [1]

Reproducer

https://github.com/microsoft/react-native-windows/pull/12761

Screenshots and Videos

No response

github-actions[bot] commented 7 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
cortinico commented 7 months ago

Yup this is a regression, to some extent.

It's not filtered in the package.json AFAIK, so maybe in some script?

We do use .npmignore to filter those out. Fix for this issue is here:

Do we need this to be backported to 0.74 @jonthysell ?

cortinico commented 7 months ago

Yup this is a regression, to some extent.

It's not filtered in the package.json AFAIK, so maybe in some script?

We do use .npmignore to filter those out. Fix for this issue is here:

Do we need this to be backported to 0.74 @jonthysell ?

cortinico commented 7 months ago

Do we need this to be backported to 0.74 @jonthysell ?

Ping here @jonthysell as we need to know if this needs to go inside RC3 or not 👍

jonthysell commented 7 months ago

Do we need this to be backported to 0.74 @jonthysell ?

Ping here @jonthysell as we need to know if this needs to go inside RC3 or not 👍

@cortinico It would be good to get into 0.74 but I don't think it's a high priority. We haven't even snapped RNW's 0.74 yet, and our workaround was to add that folder to ignore in our .flowconfig to fix the flow checks. Having the files present doesn't seem to have any other side-effects for us AFAIK.