-- ROBLOX deviation END chalk_supportsColor
-- ROBLOX deviation END chalk_chainable


exports.default = function(result: TestResult, globalConfig: Config_GlobalConfig, projectConfig: Config_ProjectConfig?)
	local testPath = result.testFilePath
	local formattedTestPath = formatTestPath(projectConfig or globalConfig, testPath)
	-- ROBLOX deviation START: no terminal-link package available just use the path
	local fileLink = formattedTestPath
	-- ROBLOX deviation END
	if result.numFailingTests == nil then
		result.numFailingTests = 0
	end
	local status = if result.numFailingTests > 0 or result.testExecError ~= nil then FAIL else PASS
	local testDetail = {}

	if result.perfStats ~= nil and Boolean.toJSBoolean(result.perfStats.slow) then
		local runTime = result.perfStats.runtime / 1000
		table.insert(testDetail, LONG_TEST_COLOR(formatTime(runTime, 0)))
	end

	if result.memoryUsage ~= nil then
		local toMB = function(bytes: number)
			return math.floor(bytes / 1024 / 1024)
		end
		table.insert(testDetail, (" %sMB heap size"):format(tostring(toMB(result.memoryUsage))))
	end

	local projectDisplayName = if projectConfig ~= nil and Boolean.toJSBoolean(projectConfig.displayName)
		then printDisplayName(projectConfig) .. " "
		else ""

	return string.format("%s %s%s %s", status, projectDisplayName, fileLink, table.concat(testDetail, " "))
end

return exports
