This is the monorepo for integrating the test-runner of your choice into your Quasar app.
You can install multiple pre-rigged testing harnesses (test runners) to your existent Quasar application by running a simple command which will:
You can add multiple harnesses and even use them for your continuous integration pipelines.
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.
$ cd your-quasar-project $ quasar ext add @quasar/testing
This creates a
test folder to hold all of your test related files and adds several new configuration files to the root folder of your project:
quasar.testing.json=> records the commands relevant to respective harnesses
quasar.extensions.json=> individual extension options
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 test 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 tha base package or have any problems with it whatsoever, you can install each test harness app extension individually as they are completely standalone.
Note: All the examples use the unit-jest package. However, the process is the same for other packages as well.
If you mess up your configuration and need to reset - or just want the latest Quasar-approved packages, this would be the way to do it:
$ quasar ext add @quasar/testing-unit-jest
Be careful though, reinstalling will overwrite ALL existing files (including configurations) if you tell it to. Also, it will install the new packages (if there are any). To prevent installing new or updated node modules, you may do this:
$ quasar ext invoke @quasar/testing-unit-jest
If you are using npm for package management, you’ll need to force a major version upgrade before updating
npm install --save-dev @firstname.lastname@example.org
Once this is run, you can update/reset the extension as before
quasar ext add @quasar/testing-unit-jest
Since there are major changes, in order not to miss out on new config, you may consider first ensuring your source control is clean, then answer (y) and “Overwrite all” when being requested to reinstall existing files and configuration. Then individually
git diff all changes manually to see what changes you want to keep or merge in
If you want to remove the testing harness, you can run:
$ quasar ext remove @quasar/testing-unit-jest
This will remove the associated node module and its dependencies, but it will not delete or modify any files.
$ quasar ext add @quasar/testing-unit-ava
We have included:
We have included the optional ability to place your test code inside your vue files, should you choose to do so. It will be rendered by webpack HMR. To run these tests, run
$ quasar test --unit ava --dev.
<test lang="ava"> /* your complete test file here */ </test>
You may notice that your IDE doesn’t know how to parse the test block, so go into the
<alt> + <enter>, select ‘inject language or reference’ and select
We recommend testing webapps with Cypress if you target Chrome-based browsers (Chrome, Edge, Electron) or Firefox - but if you want to test Safari, IE or Cordova apps, then you should consider using webdriver.io.
$ quasar ext add @quasar/testing-e2e-wdio $ yarn selenium:install && selenium:start
WIP - please help battle test this harness. FYI: we’re using webdriver 4.0 for the moment because wdio requires it. If you need to use webdriver 5, please get in touch and we can create another app-extension.
Prior Work: https://github.com/fansanelli/quasar-webdriver/blob https://github.com/NodeJunkie/quasar-webdriver/tree/feat/BackportToQuasar%231
$ quasar ext add @quasar/testing-quality
Auditing the quality of your app is something you want to do before you go in production. Depending on your perspective, quality can mean many things. So we have put together a few tools that we think can help you have a qualitatively better project.
Lighthouse tool can help you identify issues with your PWA app, but only if you serve the built version of your project. If you use it a lot, consider installing it globally.
Snyk is a tool for identifying node modules that have security implications. Running this regularly will keep you alerted to issues that may be stemming from repositories you use.
Node License Finder (nlf) is a free tool you can use to catalog all the licenses of the hundreds of open-source projects you are using in your project.
Dependency Scanning using Anti-Vulnerability Scanner
There will be more and more test-harnesses coming as time permits. If you would like to help us add official harnesses, please get in touch on Discord. Do not merely make a PR, as there are several people working in private forks and it is likely that the harness you are interested in may already be in some stage of development.
The packages in this repo are designed to be installed only by the Quasar framework. They follow the following naming convention:
Because of the way that Quasar internally maps extensions (pruning “app-extension-“), the
ava test-runner would be
Although you could probably install them all with yarn, it is highly recommended to follow the normal approach of using the quasar CLI because of the template files copied over. Furthermore, this will only work with the CLI for Quasar 1.0, not with vue-cli. If you are interested in breaking the warranty, if you were only interested in integrating the node_module dependencies from ava and spectron into your app, technically you could merely run:
$ yarn add @quasar/quasar-app-extension-testing $ yarn add @quasar/quasar-app-extension-testing-unit-ava $ yarn add @quasar/quasar-app-extension-testing-e2e-cypress
The test-driven-design approach will also help you to write better (and fewer) tests. Even though it may seem like it slows you down to some degree, this habit of great programmers pays its dividends when other developers accidentally change the interface. Think of tests like insurance for your code that always pays out.
Clone this repository and run
Then create a 1.0 Quasar app. Go into the package.json and add this line:
yarn and finally:
$ quasar ext invoke @quasar/testing-unit-%_your-harness_%
Please consult the forthcoming documentation about how to create app extensions at the main Quasar docs - or learn by copying.
Test harnesses currently verified to have valid “integration” are checked off in the following list:
Contributions to this repository are highly desirable. Before you make a PR, please open an issue, create a fork and PR. See the Contribution Guidelines for more details. Please note: Project coordination takes place on the Discord server.
Denjell would like to give a special shout out to all of the people who helped test the testing framework during the transition from 0.17 to 1.0
MIT ©2018 - present - D.C. Thompson & Razvan Stoenescu
All Icons © the respective owners