This package provides a shared Cypress configuration for E2E testing in HubSpot Marketing WebTeam projects.
For full setup instructions, see the Cypress Framework Setup guide.
npm i -D cypress@15Create a cypress.config.js file in your project root:
const { defineConfig } = require('cypress');
const { config } = require('@hs-web-team/eslint-config-node/cypress.config');
module.exports = defineConfig({
...config,
e2e: {
...config.e2e,
baseUrl: 'http://localhost:3000',
},
});For HubSpot CMS projects that use hubspot.config.yml:
const { defineConfig } = require('cypress');
const { config, envs, getBaseUrls } = require('@hs-web-team/eslint-config-node/cypress.config');
const baseUrls = getBaseUrls();
module.exports = defineConfig({
...config,
e2e: {
...config.e2e,
baseUrl: baseUrls.qa,
},
env: {
...envs,
baseUrls,
},
});- Chrome Web Security: Disabled for cross-origin testing
- Timeouts: 20s for default command, page load, and response (Cypress default is 4s)
- Viewport: 1920x1080
- Retries: 1 in run mode, 0 in open mode
- Video: Disabled by default
- Tests kept in memory: 0 (prevents memory issues)
- Spec pattern:
cypress/e2e/*.cy.js - Cucumber support: Includes Cucumber preprocessor setup with esbuild
- TypeScript support: Native via esbuild, no additional loader needed
| Export | Description |
|---|---|
config |
Main Cypress configuration object |
envs |
Environment constants (DEV, QA, PROD, currentEnv) |
setupNodeEvents |
The setupNodeEvents function (for custom extension) |
getDevBaseUrl() |
Reads baseUrl from the DEV portal in hubspot.config.yml |
getBaseUrls() |
Reads URLs for all environments from .ci/config.yml |
{
currentEnv: 'qa',
DEV: 'DEV',
QA: 'qa',
PROD: 'prod',
}Returns the baseUrl from the DEV portal in hubspot.config.yml, or null if not found.
Requirements: hubspot.config.yml must exist and the DEV portal must have a baseUrl property.
Returns base URLs for all environments:
// Returns: { DEV: '...', qa: '...', prod: '...' }The DEV key comes from getDevBaseUrl(). The qa and prod keys come from .ci/config.yml:
regression:
e2eTestEnvironment:
- name: qa
url: https://qa.example.com
- name: prod
url: https://prod.example.comsetupNodeEvents is embedded in config.e2e. If you override it without calling the package's version, you'll lose the Cucumber preprocessor and esbuild setup.
Import setupNodeEvents directly and call it first:
const { defineConfig } = require('cypress');
const { config, setupNodeEvents: wtSetupNodeEvents } = require('@hs-web-team/eslint-config-node/cypress.config');
module.exports = defineConfig({
...config,
e2e: {
...config.e2e,
async setupNodeEvents(on, cfg) {
await wtSetupNodeEvents(on, cfg);
on('task', {
log(message) {
console.log(message);
return null;
},
});
return cfg;
},
},
});If you don't need custom node events, omit setupNodeEvents entirely and just spread ...config.e2e.
JavaScript:
// Before
const { getDevBaseUrl, getBaseUrls, config, envs } = require('@hs-web-team/eslint-config-browser/cypress.config.js');
// After
const { getDevBaseUrl, getBaseUrls, config, envs } = require('@hs-web-team/eslint-config-node/cypress.config');TypeScript (module format stays the same — ESM import/export default still works):
// Before
import { getDevBaseUrl, getBaseUrls, config, envs } from '@hs-web-team/eslint-config-browser/cypress.config.js';
// After
import { getDevBaseUrl, getBaseUrls, envs, config as wtConfig } from '@hs-web-team/eslint-config-node/cypress.config';Cucumber and esbuild are bundled into config.e2e.setupNodeEvents. Remove your manual setupNodeEvents function entirely and spread ...config.e2e to inherit it automatically.
If you need to add custom tasks on top, see Add Custom setupNodeEvents.
The old pattern built the full e2e object from scratch — repeating settings already in the bundle — then assigned it:
const customConfig = { ...config };
const e2e = {
specPattern: 'cypress/e2e/**/*.feature',
baseUrl,
setupNodeEvents, // manual webpack + cucumber setup
defaultCommandTimeout: 20000, // already in bundle
retries: { runMode: 1, openMode: 0 }, // already in bundle
// ...
};
customConfig.e2e = e2e;
module.exports = defineConfig(customConfig);The new pattern spreads ...config.e2e to inherit bundled settings (including setupNodeEvents) and only adds project-specific overrides:
JavaScript:
module.exports = defineConfig({
...config,
e2e: {
...config.e2e,
specPattern: 'cypress/e2e/**/*.feature',
baseUrl,
supportFile: 'cypress/support/e2e.js',
reporter: 'mochawesome',
reporterOptions: {
reportDir: 'cypress/results',
overwrite: false,
html: true,
json: true,
},
},
});TypeScript:
export default defineConfig({
e2e: {
...wtConfig.e2e,
specPattern: 'cypress/e2e/**/*.feature',
baseUrl,
supportFile: 'cypress/support/e2e.ts',
reporter: 'mochawesome',
reporterOptions: {
reportDir: 'cypress/results',
overwrite: false,
html: true,
json: true,
},
},
blockHosts: '*.google-analytics.com',
});These are not included in the bundle and must be carried over manually if your project uses them:
reporterandreporterOptions(e.g. mochawesome)supportFileblockHostsfixturesFolder,screenshotsFolder,videosFoldertestIsolationspecPattern(if using.featurefiles — bundle default iscypress/e2e/*.cy.js)
Ensure your project has the required configuration files:
hubspot.config.ymlfor HubSpot projects.ci/config.ymlfor multi-environment setups