Pico welcomes contributions from everyone, whether it's bug fixes, new features or typo fixes.
There are two ways to test Pico's output, one being the provided visual
testing suite and two a web extension that you can test Pico on any real
world website (as long as it doesn't block eval
(which is most of them so
it's not much of an issue)).
To run any of the tests you need to use the development server:
$ npm run dev
Main bundle will be served at http://localhost:23231/index.js
and
automatically updated whether you change any of the source code.
Run Pico on any website of your choice.
-
Ensure that you have the development server running
-
Open the web extension (located in
web-ext/
in the root of this repository) in the browser of your choice - note that it has only been tested with Firefox, so YMMV. If you have Firefox Nightly installed, for convenience runnpm run dev:ext
to open the web extension in that browser - you will have the development browser separate and clean from your day to day one. -
With the opened browser, browse onto a website you want to test. You should see a browser action in your address bar.
Click on the green puzzle icon to take a screenshot, a new tab should open with the output contents in SVG form.
Separate cases to test out individual parts of the renderer.
The test suite spawns a real browser (via Playwright) and lets you compare the output screenshot from Pico to the "real" viewport.
It is designed with really quick iteration in mind and to allow you to scaffold out potential problems with the library quickly, whether it's rendering related, CORS related, or anything browser specific related.
The suite is currently only provided in an interactive form, which means that you have to use your eyes to judge whether the result is suiting or not.
-
Ensure that you have the development server running
-
Add the following to your hosts file:
127.0.0.1 test.localhost 127.0.0.1 test2.localhost 127.0.0.1 test3.localhost 127.0.0.1 test4.localhost 127.0.0.1 test5.localhost
This lets you test cross-origin related issues without having to do any complicated local DNS setup.
-
Start the interactive test REPL:
$ npm run test:interactive
An empty browser window should open (in the background if you're on macOS), this will show the output of any test you run through the console.
Opens the browser output again, useful if you happened to close the original output.
Runs a test with the specified name.
Same as run
, but will update if either the source/
directory updates or the case.
Press q to exit the watcher.
Runs all available tests.
The easiest way to add a new case is to start with an existing one and
modify it to suit your needs. For most cases you won't need any special
browser flags or extra servers - I usually just copy test/cases/hello
into
a new directory in test/cases
.
-
Create the test's directory in
test/cases
. For consistency, the name of the test case should be kebab-case. -
Add your test to
test/cases/index.ts
After that's done restart your test REPL and you'll be able to run your test case.