Morera´s theorem states:Let the function
$f: \mathbb{C} \longrightarrow \mathbb{C}$. be continuous in a simply connected open set S. If $$\oint_Cf(z)dz=0$$ for a simple closed path $C$ that lies on $S$ then $f$ is an analytic function in $S$
Let $z_0$ in $S$ and define for all $z$ in $S$
$$F(z)=\int_{z_0}^{z} f(z)dz$$ Look that $F(z)$ do not depend on the path of the curve between the integration intervals, so the function $F(z)$ is well defined. Now we need to prove that $F(z)$ is differentiable at any point $z$ in $S$, such that it derivative is $f$, by definition, $F$ and all its derivatives are analytic over $S$. now let $h$ be a complex number such that $z+h$ is in $S$, then $$\dfrac{F(z+h)-F(z)}{h}=\dfrac{1}{h}\int_{z}^{z+h} f(y)dy$$, note now that $f(z)$ is in terms of the variable $y$, so $$|\dfrac{F(z+h)-F(z)}{h}-f(z)|=|\dfrac{1}{h}\int_{z}^{z+h}(f(y)-f(z))dy|$$
The integration variable $y$ lies on the path defined by the last integral, so if $h$ tends to 0, $y$ tends to $z$ by basic complex analysis.Now , how $f$ is continuous at $z$: $f(y)$ tends to $f(z)$ as $y$ tends to $z$, so here you use epsilon, delta definition and show that
$$\lim_{h\to0}{\dfrac{F(z+h)-F(z)}{h}}=f(z)$$
Morera's theorem, when properly(1) stated, is indeed the exact converse of Goursat's theorem.
Theorem (Morera): Let $\Omega\subset\mathbb{C}$ open, and $f\colon\Omega\to\mathbb{C}$ a continuous function. If for all triangles $T\subset\Omega$ whose interior is also contained in $\Omega$ $$\int_T f(z)\,dz = 0,$$ then $f$ is holomorphic in $\Omega$.
Instead of triangles, one could of course also use rectangles, or other polygons. And actually, we could drop the condition that the interior of the triangle be contained in $\Omega$ and be left with a still true, but arguably less useful result, since we would then have a sufficient but not necessary condition (consider $1/z$ on $\mathbb{C}\setminus \{0\}$ to have function satisfying the condition as stated, but not the stronger condition one obtains by dropping "whose interior is also contained in $\Omega$").
The condition entails the existence of local primitives of $f$, i.e. every $z\in \Omega$ has a neighbourhood $U$ such that $f = F'$ for a holomorphic function $F$ on $U$. Thus $f$ is holomorphic on $U$ (the derivative of a holomorphic function is again holomorphic), and since holomorphicity is a local property, $f$ is holomorphic on $\Omega$.
To establish the existence of local primitives, one considers (for example) for $z_0 \in \Omega$ a disk $U = D_r(z_0) \subset \Omega$, and on $U$ the function $F(z) = \int_{z_0}^z f(\zeta)\,d\zeta$. The vanishing of the integral of $f$ over triangles whose interior is contained in $\Omega$ then yields $F(z) - F(w) = \int_w^z f(\zeta)\,d\zeta$, from which $F' = f$ follows with the continuity of $f$.
(1) The term "properly" means "properly for this purpose", or "adequately to show it is the converse of Goursat's theorem" here. Stating it for simply connected domains or disks is not wrong.
There is one downside to stating it explicitly for simply connected domains, however. Often, people aren't aware of the local character of the theorem, and consider the simple connectedness as essential for the validity of the theorem. The essential point is the locality, that one considers not the entire domain $\Omega$, but a small convex neighbourhood $U\subset \Omega$ of a point $z\in \Omega$ to construct the local primitive.
Best Answer
The usual statement of Morera's Theorem is the following:
If $f$ is continuous on a domain $D$ and the integral of $f$ over any triangle in $D$ is $0$ the $f$ is analytic in $D$.
This has nothing to do with existence of a primitive and it does not require the domain to be simply connected. If you want to say that $f$ has a primitive then you have to assume that the region is simply connected.
PS: A primitive does exist locally for any domain but there need not be a global primitive.