Cypress plugin for sending snapshots to basset
npm install @getbasset/cypress-plugin
-
Add the following to
support/index.js
:the task submitBassetBuild will submit all the snapshots after the build has been completed.
require('@getbasset/cypress-plugin/lib/commands'); after(() => { cy.task('submitBassetBuild'); });
-
Add the
require('@getbasset/cypress-plugin')(module);
toplugins/index.js
, the default file should look like this:module.exports = (on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config } require('@getbasset/cypress-plugin')(module);
-
To take a snapshot within a test use this command:
each property in options is optional
const options ={ widths: '720,1280', hideSelectors: '.hide-me', selectors: '.css-selector', browsers: 'firefox,chrome' } cy.snapshot('title', options); //or cy.snapshot('title');
-
Run cypress with the following environmental variables:
BASSET_URL = 'url_to_basset' BASSET_TOKEN = 'projectToken' BASSET_ASSETS = '' npx cypress open
You can also set
BASSET_TMP_DIR
to the directory you want to store snapshots until the build is completed