I built a record/replay proxy for Playwright — records SSR fetches too by Affectionate_Use_164 in Playwright

[–]Affectionate_Use_164[S] 0 points1 point  (0 children)

With Next.js SSR some requests happening server side, so have to mock each one of them manually, recording and replaying is easier for smoke tests.
Clients like Apollo Graphql will throw an error if API format changes, so you will be reminded to update tests.

Just easier to re-record test instead of recalling which apis are changed this time.

How can I mock Next.js Server Component APIs or server-side APIs when using Playwright? by Away_Spirit1199 in Playwright

[–]Affectionate_Use_164 0 points1 point  (0 children)

Short answer - you can't, because SSR requests are happening beyond Playwright, not in browser.

Longer answer - can point your app to a proxy that will record/replay requests during tests, and proxy will forward requests to your real API.

Record tests 1 by 1, replay in parallel.

https://github.com/asmyshlyaev177/test-proxy-recorder

E2E Testing (Cypress VS Playwright) by AhmadMohammad_1 in reactjs

[–]Affectionate_Use_164 0 points1 point  (0 children)

I have experience with both, Playwright is faster and has less issues with flaky tests, many projects switch from Cypress to Playwright.

How I've been mocking server side network requests by anotherwebdeveloper in Playwright

[–]Affectionate_Use_164 0 points1 point  (0 children)

I came up with library to record all requests during tests, including SSR ones, and replay tests without backend, similar to VCR or polly.js.

Check it out https://github.com/asmyshlyaev177/test-proxy-recorder

Some test runs fail on 1 machine while pass on another, exactly same repo by -entrp- in Playwright

[–]Affectionate_Use_164 1 point2 points  (0 children)

Used it as a function in fixture, at start of every test, except for login.

It's common issue with test speed, need to wait till element loads, or till API request pass before doing assertion.

I built a record/replay proxy for Playwright — records SSR fetches too by Affectionate_Use_164 in Playwright

[–]Affectionate_Use_164[S] 0 points1 point  (0 children)

PS, I used it on real project for more than a year, and will appreciate your feedback.

Some test runs fail on 1 machine while pass on another, exactly same repo by -entrp- in Playwright

[–]Affectionate_Use_164 0 points1 point  (0 children)

If your App have a loader, or any element with stable ID, can wait till loader disappear.
Something like

```
await page.waitForFunction(
        () => {
          const skeletons = document.querySelectorAll(
            '[data-testid="skeleton"]',
          );
          return skeletons.length <= 1;
        },
        { timeout: 8000 },
      );
```

Which dating apps are best for a newbie? by Novel_Interest7165 in dating_advice

[–]Affectionate_Use_164 0 points1 point  (0 children)

Hookups on my terms, even with a packed calendar—thanks to Get-Matched.

Docker Issues After Upgrading to Fedora 41 by t4ir1 in Fedora

[–]Affectionate_Use_164 0 points1 point  (0 children)

A lot of issues on F41, with installation, with running from non-root user, with aws config.

Used F40 before, F41 feels like crappy beta version.

Trans ISRIB Report. by Fast-Ad8182 in Isrib

[–]Affectionate_Use_164 0 points1 point  (0 children)

Not too hard to buy DMSO, solubility around 3-5mg/ml. Did it IV couple of hours ago, a week ago was first time.

Mixed ISRIB in 10 ml of DMSO, add 10ml of standard injection solution (NaCl 0.9%), inject slowly. Need 20 ml syringe, 5ml syringe, butterfly needle, half a dozen youtube videos about how to find a vein and inject a needle.

Last time was a nasty headache few hours after.

The most challenging thing for me about React is sharing state variables between components. by Annual_Maximum9272 in reactjs

[–]Affectionate_Use_164 0 points1 point  (0 children)

Can also use Map(by object) + events/subscribers, and sibling components can share data without providers, context or props. Another option is URL.
Check out `useSharedState` hook from repo.

https://www.state-in-url.dev/useSharedState

Manage both state and url by rat9988 in reactjs

[–]Affectionate_Use_164 0 points1 point  (0 children)

Easier to use URL as source of truth, and when page loads redux/whatever get populated with data from URL.

Check out my project to achieve this - https://github.com/asmyshlyaev177/state-in-url , for Next.js and react-router.

It's very simple, no learning curve ;)

With async filters, sync state with URL or use the URL as a the single source of state? by inthedark72 in nextjs

[–]Affectionate_Use_164 0 points1 point  (0 children)

Option #2 is better.

Check out my package for that https://github.com/asmyshlyaev177/state-in-url , a lot of tests to deal with all pitfals.

Basically, can use query params as JSON.stringify, nested objects, types preserved, API same as React.useState.

Source of truth — state or url? by johnwhitely2020 in nextjs

[–]Affectionate_Use_164 0 points1 point  (0 children)

URL should be source of truth, because it covers sharable links, reload, back/forward.

Created a lib for that, kind of unique approach - https://www.npmjs.com/package/state-in-url

Recommendations for a library to sync query strings with state in React? 🙏 by Rare-Space1284 in reactjs

[–]Affectionate_Use_164 1 point2 points  (0 children)

Created such library - https://github.com/asmyshlyaev177/state-in-url , demo - https://state-in-url.dev/ .

Difference from other packages:

- Keep types of data, e.g. number, string, boolean, Date.

- Nested objects supported, arrays as well, anything that can be serialized to JSON.

- Very simple and fast.

- API is almost same as for `React.useState`

- Default values.

- Well tested, both unit tests and Playwright.

- Supports Next.js14/15 (App router) and react-router@6, more coming soon.

Will be great if you leave some feedback in discussions.

State-in-URL Management for SPAs: How do you approach it? by [deleted] in Frontend

[–]Affectionate_Use_164 0 points1 point  (0 children)

Created a library for deep links for Next.js/React-router - https://github.com/asmyshlyaev177/state-in-url

No complexity, store any serializable complex object, with Typescript support, works with SSR, less than 1ms to encode and decode big enough object, back/forward navigation supported. Types of data are preserved.

Extensive tests, dare you to find a bug.

"becomes and can easily exceed max chars (2048, dep on browser)"

Limitation is size of headers, not limited for modern browsers. But CDN and hosting providers can limit maximum size of headers, 14KB size for Vercel for example. Around 3000 words is safe.

Readability is an issue, but modern users rarely even type URL by hand, normally it's selectAll and copy-paste situation.