Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/indoorvivants/weaver-playwright
Thin integration between Weaver testing framework (https://disneystreaming.github.io/weaver-test/) and Playwright (https://playwright.dev/) for frontend testing
https://github.com/indoorvivants/weaver-playwright
playwright scala testing
Last synced: about 2 months ago
JSON representation
Thin integration between Weaver testing framework (https://disneystreaming.github.io/weaver-test/) and Playwright (https://playwright.dev/) for frontend testing
- Host: GitHub
- URL: https://github.com/indoorvivants/weaver-playwright
- Owner: indoorvivants
- Created: 2022-09-28T07:05:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-19T20:25:22.000Z (11 months ago)
- Last Synced: 2024-02-19T21:39:21.722Z (11 months ago)
- Topics: playwright, scala, testing
- Language: Scala
- Homepage:
- Size: 78.1 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [Weaver](https://disneystreaming.github.io/weaver-test/) + [Playwright](https://playwright.dev/java/docs/intro)
[![core Scala version support](https://index.scala-lang.org/indoorvivants/weaver-playwright/core/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/indoorvivants/weaver-playwright/core)Love Weaver? Like Playwright? Forced to write tests?
Very small integration between Playwright and Weaver to facilitate browser testing of applications.
Here's an example of usage which is also a [Scala CLI](https://scala-cli.virtuslab.org/) script!
**test.scala**
```scala mdoc
//> using lib "com.indoorvivants.playwright::weaver:0.0.4"
//> using lib "com.disneystreaming::weaver-cats:0.8.0"import com.indoorvivants.weaver.playwright._
import cats.effect._object Example extends weaver.IOSuite with PlaywrightSpec {
def sharedResource: Resource[IO, Res] = PlaywrightRuntime.create()pageTest("hello playwright!") { pc =>
for {
_ <- pc.page(_.navigate("https://playwright.dev"))_ <- pc.locator("text=Get Started").map(_.first().click())
_ <- eventually(pc.page(_.url())) { url =>
expect(url.contains("intro"))
}
} yield success
}
}
```Run it with `scala-cli test test.scala`.
For more common build tools:
**SBT**
```scala
"com.indoorvivants.weaver" %% "playwright" % "" % Test
```**Mill**
```scala
ivy"com.indoorvivants.weaver::playwright:"
```## What does it do?
1. Wraps Playwright and browser instantiation into a `Resource`
- And also handles bonkers exceptions it throws when the drivers are created concurrently
2. Does _minimal_ wrapping of the side-effectful, non-RT APIs that Playwright exposes
- As I learn more about frontend testing, the number of wrapped APIs should increase,
but the goal is to mainly access them via the `.page(...)` combinator3. Puts semaphores in place to abide by Playwright's [recommendation](https://playwright.dev/java/docs/test-runners#running-tests-in-parallel)
4. Provides a `eventually` combinator for retrying assertions
As you can see, it's intentionally minimal