Skip to content

Adds end to end server-client testing to miso-tests#1402

Draft
Zer0- wants to merge 80 commits intodmjio:masterfrom
Zer0-:miso-testing
Draft

Adds end to end server-client testing to miso-tests#1402
Zer0- wants to merge 80 commits intodmjio:masterfrom
Zer0-:miso-testing

Conversation

@Zer0-
Copy link
Copy Markdown
Contributor

@Zer0- Zer0- commented Feb 7, 2026

This PR adds two tests:
- TestApp: generates a random html page with a link, clicks the link and
makes sure the app reacts to it (which implies hydration was successful)
- TestBindingsApp: Creates a variable-length chain of components with
variables bound to one another. The expectation is a change to
the value of the first component will propagate all the way down each component
and come back up to change a second value in the first component.

In order to test end-to-end playwright.ts was changed to be an http endpoint, that
way our haskell test server can control playwrite, which in turn points a browser at
the test server.
- Note: The changes to playwright.ts were almost entirely vibe-coded and then
tested by hand. It could definitely be slimmed down but I lack the motivation
atm.

There is also the server module TestServer that uses environment variables
to determine whether to link to the ghcjs or wasm payloads in the html, as well
as serving the initial html for each test. The tests rely on quickcheck's ioProperty,
for each iteration the actual http server is started in the background and the
test makes an http request to the playwright server to hit the server.

TODO:

  • add asserts to bindings test
  • possibly rename the new binaries to something other than integration-* if that's more appropriate
  • comment out or delete serveFailed in TestServer (though it's useful)

I definitely expect a good amount of comments but I do think this way of testing is necessary.

Zer0- and others added 30 commits December 30, 2025 21:11
- Lower the test to mount 10k components to 10 so it won't take forever
- so far only js version
- add executable integration-tests-server section to
  tests/miso-tests.cabal
- remove tests/CHANGELOG.md and it's mention in the cabal file because
  it was making the build fail
- vibe code a generator
    - missing some sections
- see how we can generate an explicit seed in QuickCheck
- compiles
- adds missing sections
- might throw this out
- quickcheck, even when using the exact same seed (which had to be
  generated as an Int32 because haskell's Int range is a lot larger than
  javascript's Number), does not generate the same view.
- have an intermediate html representation we can ship to the client
- this time it's hand written and cleaner
- no errors according to w3c validator
    - except for the defer attribute on the script tag for loading the
      app, but that can't be the issue otherwise the app wouldn't even
      boot (defer should be present or not present, it shouldn't have a
      value)
- even the simplified html generation causes hydration issues (need to
  investigate this)
- javascript backend only, wasm is TODO
- tests pass
- There's a change to nix/haskell/packages/ghc/default.nix where I added
  the -fssr flag to miso, this fixes my test but i'm not sure if it
  breaks something else.
- also commit a js file to load the wasm script
- need to make client work with new test, which means being able to
  hydrate different kinds of data.
- should this work? This may be a failing test case
- missing assertions that should run clientside
- all small API changes
- TODO:need to replace jsaddle with miso's internal API
- rename mount -> mount_
- TODO: fix ToJSON/FromJSON instance (use miso's json instead of aeson?)
- Miso.JSON seems to be missing some implementation server-side ?
This PR adds JSON encoding to `Text` when using vanilla GHC.

- [x] Add `encode`
Zer0- and others added 22 commits March 12, 2026 17:03
- add more buttons to TestBindingsApp
- Refactor TestServer a bit
- Includes some adhoc things that should be deleted
- check if its a whole number, and if it is
  round to an Int first. This is better for APIs
  that require properly formatted integers
- Because the json Value for Number uses Double this
  may not work for the result of math operations
  but it should work if you create the Value directly from an Int
This gives `Miso.JSON` identical behavior to `JSON.stringify` and
`aeson`'s `encode`, for `encodePure`.

```javascript
> JSON.stringify(10.0)
> "10"
```

```haskell
ghci> import Data.Aeson
ghci> encode (10 :: Int)
"10"
```

Co-authored-by: Zer0- <phil.volguine@gmail.com>
This reverts commit a32d8a4.
This commit was superceeded by f9bca22
- this patch WAS vibecoded I am sorry.
This reverts commit 57127c7.
This was superceeded by dmjio#1489
- it seems the CI server times out waiting for networkidle, which
  results in a NAVIGATION_ERROR and the test suite fails
- sometimes the browser fails to load a resource and the test never
  actually runs but times out
- this is a very quick, not well thought out commit that's mean to give
  it a chance to retry
- something is failing even with retry logic
- we are closing the page
- the server appears to be serving up our files
- i'm not sure if this will help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants