Skip to content

Commit f7f43fa

Browse files
authored
Add playwright to js-environments (#624)
1 parent a989380 commit f7f43fa

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

doc/project/js-environments.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,58 @@ jsEnv := PhantomJSEnv(args = Seq("arg1", "arg2")).value
6969
For more options of the PhantomJS environment, see
7070
[the Scaladoc of `PhantomJSEnv`]({{ site.production_url }}/api/sbt-scalajs-env-phantomjs/1.0.0/org/scalajs/jsenv/phantomjs/sbtplugin/PhantomJSEnvPlugin$$autoImport$.html).
7171

72+
## Playwright
73+
[Playwright](https://playwright.dev/) is a comprehensive testing library, enabling automation of Chromium, Firefox, and WebKit browsers.
74+
75+
It supports multiple platforms and languages, including Mobile Web, making it an optimal choice for testing JavaScript in real browser environments.
76+
77+
[`scala-js-env-playwright`](https://github.com/gmkumar2005/scala-js-env-playwright) is an independent project that offers a `JSEnv` that uses Playwright for JavaScript execution.
78+
79+
The playwright-based `jsEnv` can be enabled by adding the following settings in `build.sbt`
80+
```scala
81+
jsEnv := new PWEnv(
82+
browserName = "chrome",
83+
headless = true,
84+
showLogs = true
85+
)
86+
```
87+
Addtionally it requires the following line in `project/plugins.sbt`:
88+
```scala
89+
// For Scala.js 1.x
90+
libraryDependencies += "io.github.gmkumar2005" %% "scala-js-env-playwright" % "0.1.8"
91+
```
92+
93+
The `browserName` parameter accepts `chrome` , `chromium` , `firefox`, and `webkit` as possible options.
94+
95+
Please be aware that webkit support is currently in an experimental stage.
96+
97+
### In browser debugging
98+
To maintain the browser window open post-execution, add the `withKeepAlive` option into the environment.
99+
100+
```scala
101+
lazy val pwenvConfig = Def.setting {
102+
jsenv.playwright.PWEnv
103+
.Config()
104+
.withKeepAlive(true)
105+
}
106+
107+
jsEnv := new jsenv.playwright.PWEnv(
108+
browserName = "chrome",
109+
headless = true,
110+
showLogs = true,
111+
pwenvConfig.value,
112+
)
113+
114+
```
115+
### Headless Usage
116+
Running in headless mode is crucial for operations within Docker containers and build servers.
117+
118+
By default, `scala-js-env-playwright` operates in headless mode.
119+
However, for debugging purposes, you can set headless to `false`.
120+
121+
## Details
122+
For more options of the plawwright environment see the github project [PlayWright-jsEnv](https://github.com/gmkumar2005/scala-js-env-playwright)
123+
72124
## Selenium
73125

74126
[Selenium](http://docs.seleniumhq.org/) provides a programmatic interface to real browsers.

doc/tutorial/basic/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ After reloading, you can invoke `run` successfully:
351351
[info] Running tutorial.webapp.TutorialApp
352352
[success] (...)
353353

354-
Alternatively to Node.js with jsdom, you can use [Selenium](http://docs.seleniumhq.org/).
354+
Alternatively to Node.js with jsdom, you can use [Selenium](http://docs.seleniumhq.org/) or [Playwright](https://github.com/gmkumar2005/scala-js-env-playwright)
355355
You can find more information about this in the [documentation about JavaScript environments]({{ BASE_PATH }}/doc/project/js-environments.html).
356356

357357
### Adding uTest

0 commit comments

Comments
 (0)