local d local i local F local k=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\106\101\115\116-\103\108\111\098\097\108\115")local b=k.expect local a=k.beforeEach local M=k.jest local B=k.it a(function()M.resetModules()d=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\114\101\097\099\116")i=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\114\101\097\099\116-\110\111\111\112-\114\101\110\100\101\114\101\114")F=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\115\099\104\101\100\117\108\101\114")end)B("\115\104\111\117\108\100 \105\103\110\111\114\101 \101\114\114\111\114 \105\102 \105\116 \100\111\101\115\110\'\116 \116\104\114\111\119 \111\110 \114\101\116\114\121",function()local k=false local function a()local d=not k k=true if d then error("\072\105")end end local M=d.Component:extend("\065\112\112")function M.render(i)a()return d.createElement("\084\101\120\116\076\097\098\101\108",{Text="\072\101\108\108\111"})end i.render(d.createElement(M));(b(F)).toFlushWithoutYielding()end)
-- ROBLOX upstream: https://github.com/facebook/react/blob/d13f5b9538e48f74f7c571ef3cde652ca887cca0/packages/react-reconciler/src/__tests__/ReactIncrementalErrorReplay-test.js
--[[*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @emails react-core
 * @jest-environment node
 --]]
--!strict

local React
local ReactNoop
local Scheduler

local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
local jestExpect = JestGlobals.expect
local beforeEach = JestGlobals.beforeEach
local jest = JestGlobals.jest
local it = JestGlobals.it

beforeEach(function()
	jest.resetModules()

	React = require("@pkg/@jsdotlua/react")
	ReactNoop = require("@pkg/@jsdotlua/react-noop-renderer")
	Scheduler = require("@pkg/@jsdotlua/scheduler")
end)

-- ROBLOX deviation: this test doesn't make sense in not JSX
-- it('should fail gracefully on error in the host environment', () => {
--     ReactNoop.render(<errorInBeginPhase />);
--     jestExpect(Scheduler).toFlushAndThrow('Error in host config.');
--   });

it("should ignore error if it doesn't throw on retry", function()
	local didInit = false

	local function badLazyInit()
		local needsInit = not didInit
		didInit = true
		if needsInit then
			error("Hi")
		end
	end

	local App = React.Component:extend("App")
	function App:render()
		badLazyInit()
		return React.createElement("TextLabel", { Text = "Hello" })
	end
	ReactNoop.render(React.createElement(App))
	jestExpect(Scheduler).toFlushWithoutYielding()
end)
