cloudify-ui-common-cypress
v2.1.0
Published
Common Cloudify UI Cypress library
Downloads
283
Readme
Cloudify UI Common Cypress
This package contains resources common to Cypress tests:
- Cypress plugins setup and runtime configuration logic - see
plugins
directory - Cypress custom commands definitions - see
support
directory - Cypress runner static configuration - see
cypress.json
file
Installation
npm install cloudify-ui-common-cypress
Usage
Plugins
Cypress plugin and configuration setup can be done the following way:
// test/cypress/plugins/index.ts
import performCommonSetup from 'cloudify-ui-common-cypress/plugins';
import getWebpackConfig from '../../../webpack.config';
const setupPluginsAndConfig: Cypress.PluginConfig = (on, config) => {
config.baseUrl = 'http://localhost:9000';
return performCommonSetup(on, config, getWebpackConfig({}));
};
export default setupPluginsAndConfig;
Support
Cypress custom commands can be added the following way:
// test/cypress/support/index.ts
import './my-commands';
// test/cypress/support/my-commands.ts
import type { GetCypressChainableFromCommands } from 'cloudify-ui-common-cypress/support';
import { addCommands } from 'cloudify-ui-common-cypress/support';
declare global {
namespace Cypress {
export interface Chainable extends GetCypressChainableFromCommands<typeof commands> {}
}
}
const commands = {
myCommand: () => cy.log('This is my command')
};
addCommands(commands);
With that, you should be able to access Cypress custom command through `cy` global in your Cypress test code.
### Configuration
Cypress runner static configuration - `cypress.json` file - can be used the following way:
```npm
cypress run -C node_modules/cloudify-ui-common-cypress/cypress.json