From 6565b2b7ccf0284b0185e4755055083d3ef330be Mon Sep 17 00:00:00 2001 From: Kiran Kumar Mallru Date: Wed, 24 Jan 2024 19:49:02 +0530 Subject: [PATCH] Testing with chrome using scala-js-env-playwright with esmodules and fullLinkJS --- build.sbt | 22 +++++++++---------- project/plugins.sbt | 1 + .../com/raquo/laminar/StyleReceiverSpec.scala | 6 ++--- .../com/raquo/laminar/basic/StyleSpec.scala | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/build.sbt b/build.sbt index 7caf82e2..0d9f4940 100644 --- a/build.sbt +++ b/build.sbt @@ -75,7 +75,7 @@ lazy val website = project ) lazy val laminar = project.in(file(".")) - .enablePlugins(ScalaJSPlugin, ScalaJSBundlerPlugin) + .enablePlugins(ScalaJSPlugin) .settings( libraryDependencies ++= Seq( "com.raquo" %%% "airstream" % Versions.Airstream, @@ -135,17 +135,16 @@ lazy val laminar = project.in(file(".")) "-no-link-warnings" // Suppress scaladoc "Could not find any member to link for" warnings ), - (Test / parallelExecution) := false, - - (Test / requireJsDomEnv) := true, - - (installJsdom / version) := Versions.JsDom, - - (webpack / version) := Versions.Webpack, + (Test / parallelExecution) := true, - (startWebpackDevServer / version) := Versions.WebpackDevServer, - - useYarn := true, + jsEnv := new jsenv.playwright.PWEnv( + browserName = "chromium", + headless = true, + showLogs = false + ), + scalaJSLinkerConfig ~= { + _.withModuleKind(ModuleKind.ESModule) + }, scalaJSUseMainModuleInitializer := true, @@ -174,6 +173,7 @@ lazy val laminar = project.in(file(".")) ) ), (Test / publishArtifact) := false, + Test / scalaJSStage := FullOptStage, pomIncludeRepository := { _ => false }, sonatypeCredentialHost := "s01.oss.sonatype.org", sonatypeRepository := "https://s01.oss.sonatype.org/service/local" diff --git a/project/plugins.sbt b/project/plugins.sbt index 79c06987..0dc02ae2 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,4 @@ +libraryDependencies += "io.github.gmkumar2005" %% "scala-js-env-playwright" % "0.1.11" addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0") addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") diff --git a/src/test/scala/com/raquo/laminar/StyleReceiverSpec.scala b/src/test/scala/com/raquo/laminar/StyleReceiverSpec.scala index ba2eb417..21fb3d95 100644 --- a/src/test/scala/com/raquo/laminar/StyleReceiverSpec.scala +++ b/src/test/scala/com/raquo/laminar/StyleReceiverSpec.scala @@ -125,13 +125,13 @@ class StyleReceiverSpec extends UnitSpec { expectNode(div.of(backgroundImage is "", "Yo")) urlBus.emit(url1) - expectNode(div.of(backgroundImage is "url(/example.png)", "Yo")) + expectNode(div.of(backgroundImage is "url(\"/example.png\")", "Yo")) urlBus.emit(url2) - expectNode(div.of(backgroundImage is "url(https://example.com)", "Yo")) + expectNode(div.of(backgroundImage is "url(\"https://example.com\")", "Yo")) urlBus.emit(url3) - expectNode(div.of(backgroundImage is "url(foo.jpg)", "Yo")) + expectNode(div.of(backgroundImage is "url(\"foo.jpg\")", "Yo")) } } diff --git a/src/test/scala/com/raquo/laminar/basic/StyleSpec.scala b/src/test/scala/com/raquo/laminar/basic/StyleSpec.scala index d178df94..3657e289 100644 --- a/src/test/scala/com/raquo/laminar/basic/StyleSpec.scala +++ b/src/test/scala/com/raquo/laminar/basic/StyleSpec.scala @@ -80,7 +80,7 @@ class StyleSpec extends UnitSpec { )) expectNode( span.of( - backgroundImage is """url(example.jpg)""" + backgroundImage is """url("example.jpg")""" ) ) unmount()