diff --git a/build.sbt b/build.sbt index 94cc28b..30613dc 100644 --- a/build.sbt +++ b/build.sbt @@ -62,6 +62,7 @@ lazy val ce2 = crossProject(JSPlatform, JVMPlatform) Test / unmanagedSourceDirectories += baseDirectory.value / "../../common/jvm/src/test/scala" ) .jsSettings( + libraryDependencies += "org.scala-js" %%% "scala-js-macrotask-executor" % "1.0.0", Compile / unmanagedSourceDirectories += baseDirectory.value / "../../common/js/src/main/scala", Test / unmanagedSourceDirectories += baseDirectory.value / "../../common/js/src/test/scala", scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)) diff --git a/ce2/js/src/main/scala/munit/CatsEffectSuitePlatform.scala b/ce2/js/src/main/scala/munit/CatsEffectSuitePlatform.scala index 700f522..063003d 100644 --- a/ce2/js/src/main/scala/munit/CatsEffectSuitePlatform.scala +++ b/ce2/js/src/main/scala/munit/CatsEffectSuitePlatform.scala @@ -17,9 +17,14 @@ package munit import cats.effect.IO +import org.scalajs.macrotaskexecutor.MacrotaskExecutor + +import scala.concurrent.ExecutionContext private[munit] trait CatsEffectSuitePlatform { self: CatsEffectSuite => private[munit] def unsafeRunSyncOrForget[A](ioa: IO[A]): Unit = ioa.unsafeRunAsyncAndForget() + private[munit] def suiteExecutionContext: ExecutionContext = MacrotaskExecutor + } diff --git a/ce2/jvm/src/main/scala/munit/CatsEffectSuitePlatform.scala b/ce2/jvm/src/main/scala/munit/CatsEffectSuitePlatform.scala index f680555..4b48adf 100644 --- a/ce2/jvm/src/main/scala/munit/CatsEffectSuitePlatform.scala +++ b/ce2/jvm/src/main/scala/munit/CatsEffectSuitePlatform.scala @@ -18,6 +18,8 @@ package munit import cats.effect.IO +import scala.concurrent.ExecutionContext + private[munit] trait CatsEffectSuitePlatform { self: CatsEffectSuite => private[munit] def unsafeRunSyncOrForget[A](ioa: IO[A]): Unit = { @@ -25,4 +27,6 @@ private[munit] trait CatsEffectSuitePlatform { self: CatsEffectSuite => () } + private[munit] def suiteExecutionContext: ExecutionContext = ExecutionContext.global + } diff --git a/ce2/shared/src/main/scala/munit/CatsEffectSuite.scala b/ce2/shared/src/main/scala/munit/CatsEffectSuite.scala index ba2fd3b..85fd19b 100644 --- a/ce2/shared/src/main/scala/munit/CatsEffectSuite.scala +++ b/ce2/shared/src/main/scala/munit/CatsEffectSuite.scala @@ -27,11 +27,13 @@ abstract class CatsEffectSuite with CatsEffectFixtures with CatsEffectFunFixtures { + private val ec: ExecutionContext = suiteExecutionContext + implicit def munitContextShift: ContextShift[IO] = - IO.contextShift(ExecutionContext.global) + IO.contextShift(ec) implicit def munitTimer: Timer[IO] = - IO.timer(ExecutionContext.global) + IO.timer(ec) override def munitValueTransforms: List[ValueTransform] = super.munitValueTransforms ++ List(munitIOTransform, munitSyncIOTransform)