Your Quasar projects have the ability to add unit and e2e testing harnesses. This introduction will not go into details about how to write and use tests, for that please consult the specially prepared and maintained documentation at the Testing repo at GitHub. If you are a beginner, consider reading one of the books in the “Further Reading” section.
High level overview
You can install multiple pre-rigged testing harnesses to your existing Quasar application by running a simple command. This command will pull and install a node module (with dependencies) into your project’s
package.json, place necessary configuration files as appropriate and if you so choose, it will also add script commands that expose some of the functionality of the respective harness. You can add multiple harnesses and even use them for your continuous integration pipelines - as appropriate.
Testing is not in and of itself hard. The most complicated part is setting up the testing harness. The trick lies in knowing what to test. If you are new to testing, it is absolutely imperative that you familiarize yourself with some of the concepts and patterns. There are some links for further reading at the end of this document page.
Most Testing AEs have been migrated to be Qv2-compatible, but since some are still in alpha or beta phase existing documentation website (https://testing.quasar.dev) still refer to Qv1 AEs. You can find the updated documentation into
dev branch of quasar-testing repo.
$ cd your-quasar-project $ quasar ext add @quasar/testing
The lightweight extension installer will ask you which testing harnesses you want to install. Then it will install the respective extensions for these harnesses, which you can configure as you like. It is how multiple testing harnesses are ideally managed within a Quasar project.
It will provide you with a new
quasar run command that you can use to execute test-runners - and even your HMR dev environment at the same time. This approach can, for example, be quite helpful if you need to pass quasar.ctx to the test runner…
# Example to run jest && dev server in pwa mode $ quasar test --unit jest --dev="-m pwa"
If you ever need to review your choices you can take a look at
If you don’t want to install the base package, you don’t have to do so. You can install each test harness app extension individually. They are completely standalone, but you won’t have the tight integration with the
quasar test command functionality.
- Testing Vue.js Applications by Edd Yerburgh, the author of the
- Free Vue Testing Handbook
- Unit Testing Vue Router with Jest
- … add your suggestions here