This PR replaces the use of jest for testing with playwright and rspack. The previous unit tests were running in a node rather than web context, with some workarounds to convince the WASM files they were running in a web context. Now they run in a web context to replicate how they would be run in production.
rspack serves a simple web page that has no UI elements but includes cockle, and playwright runs the tests against that web page. This is slightly unusual use of playwright as it is intended for end-to-end tests rather than unit tests, but it does support this method of operation. The code to test runs in a browser context which communicates with a node context where the test assertions are made. We run bespoke code in the browser context using page.evaluate which can return whatever data we want (provided it can be serialized) to the node context to be checked. This has necessitated a refactor of the test code but the underlying logic is the same.
Longer term we will add some end-to-end tests using playwright, but they will probably live in the Terminal extension and we will include that CI as downstream tests in this repo's CI.
This PR replaces the use of
jest
for testing withplaywright
andrspack
. The previous unit tests were running in a node rather than web context, with some workarounds to convince the WASM files they were running in a web context. Now they run in a web context to replicate how they would be run in production.rspack
serves a simple web page that has no UI elements but includescockle
, andplaywright
runs the tests against that web page. This is slightly unusual use ofplaywright
as it is intended for end-to-end tests rather than unit tests, but it does support this method of operation. The code to test runs in a browser context which communicates with a node context where the test assertions are made. We run bespoke code in the browser context usingpage.evaluate
which can return whatever data we want (provided it can be serialized) to the node context to be checked. This has necessitated a refactor of the test code but the underlying logic is the same.Longer term we will add some end-to-end tests using playwright, but they will probably live in the Terminal extension and we will include that CI as downstream tests in this repo's CI.