-
Notifications
You must be signed in to change notification settings - Fork 12
Add Test command #75
Comments
Hello, it has been a while since I've done anything with unit tests in JavaScript. I have been thinking about checking out PlayWright and just staying in |
The gist of In our case, using
No Idea haha, I think Jest is node only and runs tests in node rather than in the browser
That's actually what the PoC does https://github.com/AngelMunoz/Nacre it simply runs in headless mode, For fable users tests could look like this |
I believe Jest can run tests in either node or the browser, but the bigger problem is that it doesn't support ES modules at all. So another tool is required to transpile es modules down to commonJS modules. Other than that, Fable.Lit uses @web/test-runner for its testing. https://fable.io/Fable.Lit/docs/testing.html. This could be a good place to get a feel for "modern" fable testing
|
I am attempting to customize the existing Fable.Mocha tests to run with Perla. So, something like Is there any way to circumvent this? Ability to pass source folder via command line would do. |
I am currently working on this in the #89 branch The PoC is done there but there are a few missing pieces
|
I tried to get preview builds a couple of weeks ago, but I never got to it. No promises but maybe in a couple of weeks I can finally get it in a well enough state to start making a few preview releases for vnext |
Is your feature request related to a problem? Please describe.
One thing perla doesn't have right now is a way to create/run tests, normally this would be complicated and messy but with the help of web test runner we can re-use those libraries to enable in-browser tests, which are the best kind since our code and tests would be running in the same environment it is going to run.
Describe the solution you'd like
As usual, the Perla CLI has to be quite simple and should be convention based
Arguments I have considered right now are:
files - a list of individual files to test
Groups - all the files under a specific path inside the testing directory
Asuming
tests
as the testing directory, example:perla --groups featureA featureB featureC/subFeatureA
Browsers - a list of specific browsers to test with
All_Browsers - test in every browser available
Describe alternatives you've considered
I have not seen any alternatives for web test runner servers in F#/.NET
Additional context
I already have a PoC in a project called Nacre as a standalone project I think it could also take off, not sure if it's worth getting this inside perla (as we did with the scaffolding features: Clam -> Perla)
Technical quirks
Inside Nacre we had to use
import maps
to mock the file that calls into the test runner's script that handles socket connections to the server, we can use/re-use the Http/SSE mechanisms we're using inside Perla instead of sockets.Following this point, we could also use import maps to let the user mock any other files and dependencies, this requires some way to specify in the mocks (either with code or a configuration property)
Considerations
Support for files other than
.js
Since these tests run on the browser they must be served somehow, so we should be able to re-use existing code inside perla like ASP.NET middleware and esbuild on-the fly compilation.
Fable projects
Fable produces JS by default so, we're covered out of the box here we just need to run fable first to have the
.test.js
files in place, we might be able to use Fable.Expect out of the box but submitting a few PR's could also get us there in case there are some issuesAnother field in the JSON configuration file
As with other configuration properties, we will provide sensible defaults out of the box, but we should be able to expose at least a few options like browsers, testing directory, test all and similar options
Run After/Before build
we can add a flag that allows to run tests before we can actually run the build command, not sure if this is actually a good thing, the users can always call the commands as required in their scripts we just need to be sure to not return 0 if a test fails
Testing Dependencies
We might to also maintain a separate set of dependencies for development, for example inside the tests of the sample project we are importing 3 dependencies:
While we could just hardcode/provide these out of the box (which could be simpler) users might have other test only dependencies that we could merge with normal dependencies
Disadvantages
playwright must be set up outside of perla, which I guess it's fine if you're a .NET dev there's a global tool, if you're a python dev you can use pip, for node there's an npx command.
CI systems must be able to run headless browsers otherwise testing in CI won't be possible. Fortunately it seems playwright has good docs we can point to and can run on major CI providers and also provides docker images
Non Goals
The text was updated successfully, but these errors were encountered: