-- ROBLOX deviation: omitted fileExists and cleanup


local function toMatchSnapshot(...)
	local args = { ... }
	local this: types.Context = args[1]
	local received: any = args[2]
	local propertiesOrHint: any = args[3]
	local hint: ConfigPath = args[4]

	local matcherName = "toMatchSnapshot"
	local properties

	local length = select("#", ...)
	-- ROBLOX deviation: all the length parameters are one more than upstream because
	-- the this parameter isn't counted in upstream
	if length == 3 and typeof(propertiesOrHint) == "string" then
		hint = propertiesOrHint
	elseif length >= 3 then
		if typeof(propertiesOrHint) ~= "table" or typeof(propertiesOrHint) == nil then
			local options: JestMatcherUtils.MatcherHintOptions = {
				isNot = this.isNot,
				promise = this.promise,
			}
			local printedWithType = printWithType("Expected properties", propertiesOrHint, printExpected)

			if length == 4 then
				options.secondArgument = "hint"
				options.secondArgumentColor = BOLD_WEIGHT

				if propertiesOrHint == nil then
					printedWithType = printedWithType
						.. "\n\nTo provide a hint without properties: toMatchSnapshot('hint')"
				end
			end

			error(AssertionError.new({
				message = matcherErrorMessage(
					matcherHint(matcherName, nil, PROPERTIES_ARG, options),
					"Expected " .. EXPECTED_COLOR("properties") .. " must be an object",
					printedWithType
				),
			}))
		end

		-- Future breaking change: Snapshot hint must be a string
		-- if (arguments.length === 3 && typeof hint !== 'string') {}

		properties = propertiesOrHint
	end

	return _toMatchSnapshot({
		context = this,
		hint = hint,
		isInline = false,
		matcherName = matcherName,
		properties = properties,
		received = received,
	})
end
