From 9075365c2ea8cc40ce63fa96cbe29e9a6c988b0e Mon Sep 17 00:00:00 2001 From: pierrezimmermann Date: Mon, 21 Aug 2023 19:02:46 +0200 Subject: [PATCH 1/2] fix: flatlist not rendering in rntl repo --- babel.config.js | 1 - package.json | 1 - .../__snapshots__/render-debug.test.tsx.snap | 4 ++-- src/__tests__/render.test.tsx | 14 +++++++++++++- yarn.lock | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/babel.config.js b/babel.config.js index 9c4d66f5f..9d2067630 100644 --- a/babel.config.js +++ b/babel.config.js @@ -12,7 +12,6 @@ module.exports = { }, ], ], - plugins: ['@babel/plugin-proposal-class-properties'], env: { test: { // https://github.com/react-native-community/upgrade-support/issues/152 diff --git a/package.json b/package.json index d2b11be9f..1a9cd9aac 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "devDependencies": { "@babel/cli": "^7.19.3", "@babel/core": "^7.20.2", - "@babel/plugin-proposal-class-properties": "^7.18.6", "@babel/plugin-transform-flow-strip-types": "^7.19.0", "@babel/preset-env": "^7.20.2", "@babel/preset-flow": "^7.18.6", diff --git a/src/__tests__/__snapshots__/render-debug.test.tsx.snap b/src/__tests__/__snapshots__/render-debug.test.tsx.snap index e72298ccc..088df7819 100644 --- a/src/__tests__/__snapshots__/render-debug.test.tsx.snap +++ b/src/__tests__/__snapshots__/render-debug.test.tsx.snap @@ -393,7 +393,7 @@ exports[`debug: shallow 1`] = ` value="" /> Change freshness! @@ -445,7 +445,7 @@ exports[`debug: shallow with message 1`] = ` value="" /> Change freshness! diff --git a/src/__tests__/render.test.tsx b/src/__tests__/render.test.tsx index 1546b42b9..8c7f102df 100644 --- a/src/__tests__/render.test.tsx +++ b/src/__tests__/render.test.tsx @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import * as React from 'react'; -import { View, Text, TextInput, Pressable } from 'react-native'; +import { View, Text, TextInput, Pressable, FlatList } from 'react-native'; import { getConfig, resetToDefaults } from '../config'; import { render, screen, fireEvent, RenderAPI } from '..'; @@ -254,3 +254,15 @@ test('render calls detects host component names', () => { render(); expect(getConfig().hostComponentNames).not.toBeUndefined(); }); + +test('render FlatList', () => { + const screen = render( + {item}} + /> + ); + + expect(screen.getByTestId('flatList')).toBeTruthy(); +}); diff --git a/yarn.lock b/yarn.lock index c7be757de..f7c74a37f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -312,7 +312,7 @@ "@babel/helper-remap-async-to-generator" "^7.18.9" "@babel/plugin-syntax-async-generators" "^7.8.4" -"@babel/plugin-proposal-class-properties@^7.0.0", "@babel/plugin-proposal-class-properties@^7.13.0", "@babel/plugin-proposal-class-properties@^7.18.6": +"@babel/plugin-proposal-class-properties@^7.0.0", "@babel/plugin-proposal-class-properties@^7.13.0": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz#b110f59741895f7ec21a6fff696ec46265c446a3" integrity sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ== From e69dad41b54ea38b2419d4020f62eb856b7e9025 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Tue, 22 Aug 2023 11:08:51 +0200 Subject: [PATCH 2/2] refactor: move render tests to RN tests file --- src/__tests__/react-native-api.test.tsx | 87 ++++++++++++++++++++++++- src/__tests__/render.test.tsx | 14 +--- 2 files changed, 87 insertions(+), 14 deletions(-) diff --git a/src/__tests__/react-native-api.test.tsx b/src/__tests__/react-native-api.test.tsx index 65f30c9f4..0989953a7 100644 --- a/src/__tests__/react-native-api.test.tsx +++ b/src/__tests__/react-native-api.test.tsx @@ -1,5 +1,12 @@ import * as React from 'react'; -import { View, Text, TextInput, Switch } from 'react-native'; +import { + View, + Text, + TextInput, + Switch, + ScrollView, + FlatList, +} from 'react-native'; import { render } from '..'; /** @@ -124,3 +131,81 @@ test('React Native API assumption: renders single host element', () => /> `); }); + +test('ScrollView renders correctly', () => { + const screen = render( + + + + ); + + expect(screen.toJSON()).toMatchInlineSnapshot(` + + + + + + `); +}); + +test('FlatList renders correctly', () => { + const screen = render( + {item}} + /> + ); + + expect(screen.toJSON()).toMatchInlineSnapshot(` + + + + + 1 + + + + + 2 + + + + + `); +}); diff --git a/src/__tests__/render.test.tsx b/src/__tests__/render.test.tsx index 8c7f102df..1546b42b9 100644 --- a/src/__tests__/render.test.tsx +++ b/src/__tests__/render.test.tsx @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import * as React from 'react'; -import { View, Text, TextInput, Pressable, FlatList } from 'react-native'; +import { View, Text, TextInput, Pressable } from 'react-native'; import { getConfig, resetToDefaults } from '../config'; import { render, screen, fireEvent, RenderAPI } from '..'; @@ -254,15 +254,3 @@ test('render calls detects host component names', () => { render(); expect(getConfig().hostComponentNames).not.toBeUndefined(); }); - -test('render FlatList', () => { - const screen = render( - {item}} - /> - ); - - expect(screen.getByTestId('flatList')).toBeTruthy(); -});