
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@quasar/quasar-app-extension-testing-e2e-cypress
Advanced tools
A Quasar App Extension for Cypress e2e
You’re looking at Cypress AE v5 (Cypress 12 & 13) docs. If you're searching for Cypress AE v4 (Cypress 9) docs, head here
$ npm quasar ext add @quasar/testing-e2e-cypress
# or
$ yarn quasar ext add @quasar/testing-e2e-cypress
# or
$ pnpm quasar ext add @quasar/testing-e2e-cypress
For ESLint < v9, add into your .eslintrc.js the following code:
{
// ...
overrides: [
{
files: ['test/cypress/**/*.{js,jsx,ts,tsx}', '**/*.cy.{js,jsx,ts,tsx}'],
extends: [
// Add Cypress-specific lint rules, globals and Cypress plugin
// See https://github.com/cypress-io/eslint-plugin-cypress#rules
'plugin:cypress/recommended',
],
},
],
}
For ESLint v9 onwards, add into your eslint.config.js the following code:
import pluginCypress from 'eslint-plugin-cypress/flat';
export default [
// ...
{
name: 'custom/cypress',
files: ['test/cypress/**/*.{js,jsx,ts,tsx}', '**/*.cy.{js,jsx,ts,tsx}'],
extends: [
// Add Cypress-specific lint rules, globals and Cypress plugin
// See https://github.com/cypress-io/eslint-plugin-cypress#rules
pluginCypress.configs.recommended,
],
rules: {
// Allow chai-style assertions, e.g. `expect(foo).to.be.true`
'@typescript-eslint/no-unused-expressions': 'off',
},
},
];
This App Extension (AE) manages Quasar and Cypress integration for you, both for JavaScript and TypeScript.
Some custom commands are included out-of-the-box:
| Name | Usage | Description |
|---|---|---|
dataCy | cy.dataCy('my-data-id') | Implement the selection best practice which avoids brittle tests, is equivalent to cy.get('[data-cy=my-data-id]') |
selectDate | cy.get('.q-date').selectDate('2023/02/23') | Select a given date into a QDate component, it accept either a Date object or a string which new Date(myDate) can parse correctly |
testRoute | cy.testRoute('home') cy.testRoute('books/*/pages/*') | Test if the current URL matches the provided string using minimatch. Leading #, if using router hash mode, and / are automatically prepended. |
within[Portal|Menu|SelectMenu|Dialog] | cy.withinSelectMenu(() => cy.get('.q-item').first().click()) cy.withinDialog({ dataCy: 'add-action-dialog', fn() { /* business haha */ } }); | Auto-scope commands into the callback within the Portal-based component and perform assertions common to all of them. |
should('have.[color|backgroundColor]') | cy.get('foo').should('have.color', 'white') cy.get('foo').should('have.backgroundColor', '#000') cy.get('foo').should('have.color', 'var(--q-primary)') | Provide a couple color-related custom matchers, which accept any valid CSS color format. |
Check out how to use these commands, and other recipes about testing Quasar UI components, into our automated tests suite.
You must have a running dev server in order to run integration tests. The scripts added by this AE automatically take care of this: yarn test:e2e and yarn test:e2e:ci will launch quasar dev when starting up the tests and kill it when cypress process ends.
This AE is a wrapper around Cypress, you won't be able to use this or understand most of the documentation if you haven't read the official documentation.
Cypress Component Testing is supported and the AE scaffolds the code to run both "e2e" and "component" tests with Cypress.
As for "e2e" tests, you'll need to first take a look to their official documentation, or you won't understand many of the concepts described into this documentation.
Consequentially, we may rename this package from @quasar/quasar-app-extension-testing-e2e-cypress to @quasar/quasar-app-extension-testing-cypress in a future release.
We support scaffolding code coverage configuration for Cypress tests, when using Vite-based Quasar CLI.
To generate reports, run test:e2e:ci and/or test:component:ci scripts.
Running them both sequentially within the same command (eg. yarn test:e2e:ci && yarn test:component:ci) will result in combined coverage report.
You'll find the generated report into coverage/lcov-report folder.
We provide a preset configuration for the coverage report which:
all option to include some files which are ignored by default:
__tests__) and TS declaration files (*.d.ts), which should already be excluded by default but apparently aren't;Check out nyc official documentation if you want to customize report generation.
You can either add options into .nycrc file or generate reports on the fly running nyc report <options>.
If you want to override the options that are defined by our preset configuration(or any preset), you should be aware of this nyc issue.
You can either apply this workaround or embed our preset configuration into your .nycrc file directly, instead of extends.
Note that we do not setup Istanbul TS configuration and its dependencies as Cypress claims it's able to manage TS code coverage out-of-the-box. Some TS files may be excluded by the report in scenarios, eg. if they aren't actually imported (dead code), if they're tree-shaked away by a bundler or if they only contain types/interfaces, and as such have no actual JS representation. Please open an issue if you notice some files are missing from generated reports in this scenario.
If you're coming from v5.1, follow the migration guide in the next section first.
Here's all the steps you need to take while upgrading from v6.1 to v6.2:
@quasar/app-webpack v4 beta version or @quasar/app-vite v2 beta version, install the latest (stable) version of those packages, as the beta versions aren't supported anymore.@quasar/app-webpack v4 or @quasar/app-vite v2, and typescript v5 or newer:
"moduleResolution": "bundler" option into compilerOptions section of your test/cypress/tsconfig.json.test:e2e, test:e2e:ci, test:component and test:component:ci scripts, replacing cross-env NODE_ENV=test with cross-env NODE_ENV=test TS_NODE_PROJECT=test/cypress/tsconfig.json."sourceMap": false option from your test/cypress/tsconfig.json. We'll keep scaffolding that option for now, to maintain compatibility with older versions of Cypress.eslint-plugin-cypress v4, as the next major version of Cypress AE won't support ESLint v8 anymore. You'll also need to update your ESLint config, so check the new installation instruction for ESLint v9 at the top of this page.We know this back and forth between adding/removing tsconfig options and script flags are annoying, but Cypress guys are having trouble properly supporting newer versions of TypeScript and it's really hard to keep up with the bugs they keep adding/removing. They should fix these problems for good in v15, subscribe to this issue for updates on the matter.
If you're coming from v4, follow the migration guide in the next section first.
Here's all the steps you need to take while upgrading from v5.1 to v5.2:
@quasar/app-webpack/@quasar/app-vite to its latest version: v5.2 leverage some features which are only available on @quasar/app-webpack@3.11.0/@quasar/app-vite@1.6.0 onwards. Notice that this means that the old @quasar/app package (old name of @quasar/app-webpack) isn't supported anymore.test:e2e and test:e2e:ci scripts to use port "8080" OR run quasar ext invoke @quasar/testing-e2e-cypress and specify your custom port. The AE now enforces the usage of "8080" port by default on the dev server for both @quasar/app-webpack and @quasar/app-vite, and for all build modes. It previously varied for each combination and Vite-based projects used "9000" port by default.cypress.config.js to cypress.config.cjs. This will avoid problems with future major versions of @quasar/app-webpack/@quasar/app-vite, in case at some point you decide to switch your project to "ESM by default" using "type": "module" option in package.json.test:e2e and test:e2e:ci scripts, since on Node 17-18-19 "localhost" will be resolved to "::1" on Windows and Mac, and this will make those scripts fail silently and hang indefinitely. Node 20 LTS correctly supports Happy Eyeball protocol and thus this fix shouldn't be neededif you're coming from v3, follow the migration guide for v4 and v4.1 first
All changes are related to Cypress v10-v11-v12 breaking changes, Quasar first-party helpers haven't been changed unless Cypress required it.
Alternatively to the following guide, a faster but more error-prone way for advanced developers would be to run yarn quasar ext add @quasar/testing-e2e-cypress and yarn add -D cypress, then let the package scaffold new files overriding the existing ones and manually merge your changes into the generated files. Even in this case, we suggest to take a look to the following migration guide and use it as a checklist, as some files must be renamed/removed.
Here's all the steps you need to take while upgrading from v4 to v5:
cypress dependency, which has been externalized and marked as a peerDependencyyarn upgrade @quasar/quasar-app-extension-testing-e2e-cypress
yarn add -D cypress
package.json. You can remove the dependency at the end of this migration guide, as @quasar/app-webpack already provides it for you.yarn add -D typescript
yarn cypress open and follow the guided procedurevue framework and webpack/vite bundler accordingly to what you're using. Note that, after the migration wizard completes, Cypress is expected to display an error due to it's inability to run Quasar devServer out-of-the-boxcomponent property is generated into cypress.config.[cjs|ts], remove the one containing devServer property.test/cypress/plugins/index.[js|ts] the code used to inject the component dev server, and add it into cypress.config.[cjs|ts] asimport { injectQuasarDevServerConfig } from '@quasar/quasar-app-extension-testing-e2e-cypress/cct-dev-server';
export default defineConfig({
// ...
component: {
devServer: injectQuasarDevServerConfig(),
},
});
test/cypress/support/component-index.html file with this contenttest/cypress/support/component-index.html property into cypress.config.[cjs|ts] to test/cypress/support/component-index.htmltest/cypress/support/component.[js|ts] replace import { config } from '@vue/test-utils'; with// Since Cypress v10 we cannot import `config` directly from VTU as Cypress bundles its own version of it
// See https://github.com/cypress-io/cypress/issues/22611
import { VueTestUtils } from 'cypress/vue';
const { config } = VueTestUtils;
mount occurrences to use the new cy.mount() helper insteadcomponent.specPattern property to src/**/*.cy.{js,jsx,ts,tsx} and update all your component tests names to match that pattern, replacing .spec.[js|ts] with .cy.[js|ts]test/cypress/integration folder to test/cypress/e2e and update e2e.specPattern accordinglytest/cypress/support/index.[js|ts] to test/cypress/support/e2e.[js|ts] and update e2e.supportFile property accordinglytest:e2e and test:e2e:ci scripts to use --e2e flag (open --e2e and run --e2e respectively)test:component and test:component:ci scripts to use --component flag instead of open-ct/run-ct commands (open --component and run --component respectively)test/cypress/plugins/index.[js|ts] to setupNodeEvents hooks into cypress.config.[cjs|ts]. Note that if you're using Vite and you added code coverage, you'll need to setup code coverage plugin both into e2e and component setupNodeEvents hookscy.saveLocalStorage and cy.restoreLocalStorage has been removed, since Cypress 12 now provides a more stable and complete solution to persist cookies, session storage and local storage across tests.Many Cypress commands rely on the presence of a native DOM inputs, but many Quasar input components won't usually render them for better performance, or will use them under the hood, but hide them to the user.
This resulted in a bad DX for some Cypress commands/assertions when used on some Quasar input components, so we patched those Cypress commands/assertions on our side. Here's the list of patched methods and some limitations due to the override:
.select()
force: true)..check / .uncheck
.should('be.checked') / .should('not.be.checked')
Feel free to open a PR if you want to help removing these limitations.
data-cyQSelect automatically apply unknown props to an inner element of the component, including data-cy.
This means that you need to use cy.dataCy('select').closest('.q-select') to get the actual root element of the component.
While this isn't important when clicking the select to open its options menu, it is if you're checking any of its attributes (eg. aria-disabled to see if it's enabled or not)
You can define an helper to access a QSelect element, here's an example:
function dataCySelect(dataCyId: string) {
return cy.dataCy(dataCyId).closest('.q-select');
}
Additionally, when using use-input prop, the data-cy is mirrored on the inner native select too.
This can generate confusion as cy.dataCy('select') in those cases will return a collection and you'll need to use .first() or .last() to get respectively the component wrapper or the native input.
This AE aims to be as lightweight as possible to reduce maintenance burden. That's why we currently don't provide our own helpers to manage VueRouter, Vuex and Pinia.
The good news is that we don't actually need to, since official documentation for those libraries is already available:
When testing components, your Quasar boot files aren't loaded. If you need some features defined in your boot files, you can manually add them in your support file.
For instance, to make an axios API client globally available, simply set it in the VueTestUtils config.global.mocks object (like you would do on app.config.globalProperties in your boot file):
import { VueTestUtils } from 'cypress/vue';
import axios from 'axios';
const api = axios.create({ baseURL: 'https://api.example.com' });
VueTestUtils.config.global.mocks.$api = api;
Vue Test Utils doesn't provide an helper to test your components vModel, so we created our own, which even allow you use refs into your tests, based on this discussion.
const model = ref(null);
mount(QSelect, {
props: {
...vModelAdapter(model),
// or, if you're using a custom name for your vModel, use
// ...vModelAdapter(model, 'myModelName'),
options,
},
});
Check out more examples here.
cd test-project-webpack # or "cd test-project-vite" or "cd test-project-app"
yarn sync:cypress # or "yarn sync:all", if it's the first time you run this command
yarn test:e2e:ci # check if e2e tests still work with the local version of the AE
yarn test:component:ci # check if component tests still work with the local version of the AE
FAQs
A Quasar App Extension for Cypress e2e
We found that @quasar/quasar-app-extension-testing-e2e-cypress demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.