feather-testing-core 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +63 -8
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,20 +1,75 @@
1
1
  # feather-testing-core
2
2
 
3
+ A readable testing DSL that turns async test boilerplate into fluent, chainable steps.
4
+
3
5
  Part of the [Feather Framework](https://github.com/siraj-samsudeen/feather-framework) ecosystem.
4
6
 
5
- Phoenix Test-inspired fluent testing DSL for Playwright and React Testing Library.
7
+ ## The Core Idea
8
+
9
+ This DSL defines a universal vocabulary — `fillIn`, `clickButton`, `assertText`, and more — that can be backed by **any** test framework. Playwright and React Testing Library are just the first two adapters. You write your tests once in a fluent, chainable style; the adapter handles the framework-specific details.
6
10
 
7
- Write browser tests that read like user stories:
11
+ ### Before / After Playwright E2E
8
12
 
13
+ **Before (Vanilla Playwright):**
9
14
  ```ts
10
- await session
11
- .visit("/projects")
12
- .clickLink("New Project")
13
- .fillIn("Name", "My Project")
14
- .submit()
15
- .assertText("My Project");
15
+ test("sign up", async ({ page }) => {
16
+ await page.goto("/");
17
+ await expect(page.getByText("Hello, Anonymous!")).toBeVisible();
18
+ await page.getByText("Sign up instead").click();
19
+ await page.getByLabel("Email").fill("e2e@example.com");
20
+ await page.getByLabel("Password").fill("password123");
21
+ await page.getByRole("button", { name: "Sign up" }).click();
22
+ await expect(page.getByText("Hello! You are signed in.")).toBeVisible();
23
+ });
24
+ ```
25
+
26
+ **After:**
27
+ ```ts
28
+ test("sign up", async ({ session }) => {
29
+ await session
30
+ .visit("/")
31
+ .assertText("Hello, Anonymous!")
32
+ .click("Sign up instead")
33
+ .fillIn("Email", "e2e@example.com")
34
+ .fillIn("Password", "password123")
35
+ .clickButton("Sign up")
36
+ .assertText("Hello! You are signed in.");
37
+ });
16
38
  ```
17
39
 
40
+ ### Before / After — React Testing Library
41
+
42
+ **Before (Vanilla RTL):**
43
+ ```ts
44
+ test("form submission", async () => {
45
+ render(<App />);
46
+ const user = userEvent.setup();
47
+
48
+ await user.type(screen.getByLabelText("Email"), "test@example.com");
49
+ await user.type(screen.getByLabelText("Password"), "password123");
50
+ await user.click(screen.getByRole("button", { name: "Sign in" }));
51
+ expect(await screen.findByText("Hello! You are signed in.")).toBeInTheDocument();
52
+ });
53
+ ```
54
+
55
+ **After:**
56
+ ```ts
57
+ test("form submission", async () => {
58
+ render(<App />);
59
+ const session = createSession();
60
+
61
+ await session
62
+ .fillIn("Email", "test@example.com")
63
+ .fillIn("Password", "password123")
64
+ .clickButton("Sign in")
65
+ .assertText("Hello! You are signed in.");
66
+ });
67
+ ```
68
+
69
+ ### Same DSL, Any Backend
70
+
71
+ Notice both examples use the **exact same methods** — `fillIn`, `clickButton`, `assertText`. The DSL is framework-agnostic. Playwright and React Testing Library are just the first two adapters. You can implement the `TestDriver` interface for any testing library and get the same fluent syntax.
72
+
18
73
  Inspired by [Phoenix Test](https://hexdocs.pm/phoenix_test/PhoenixTest.html) — Elixir's pipe-chain testing DSL.
19
74
 
20
75
  ## Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feather-testing-core",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Phoenix Test-inspired fluent testing DSL for Playwright and React Testing Library",
5
5
  "license": "MIT",
6
6
  "repository": {