embroider-build / embroider

Compiling Ember apps into spec-compliant, modern Javascript.
MIT License
329 stars 137 forks source link

Command Watcher #1877

Closed BlueCutOfficial closed 1 month ago

BlueCutOfficial commented 1 month ago

Context

When working with vite, running the dev server and generating the production build with Rollup are two different actions that both have a specific execution. For instance, when dealing with public assets provided by the app and addons:

This case highlights why we need to test some behaviors for both dev mode and build mode now the test suite is using vite.

Testing dev mode easily

This PR implements a CommandWatcher utility to ease running a vite dev server in tests. It relies on the former EmberCLI class that was used to run ember serve, but it makes it more generic (you can now choose the name of the command like ember or vite) and it makes it an importable helper so we can test the dev mode in multiple test files.

Compat dummy app test

The first use case for the new CommandWatcher is the compat-dummy-app-test. This PR prepares the field so the tests that check public assets presence now use vite and check both the dev mode and the build.

This preparation work is required to complete #1859, which will remove the part of the code that is now managed by the assets plugin: in #1859, compat-dummy-app-test will have to stop testing public assets are present in the rewritten app and instead test they are present in the dist (in build mode) or served correctly (in dev mode).

Here, aside of the assertions, we do the following things: