Integration · Test framework · via REST API

Fresh, masked test data for Cypress tests

Refresh the test database before your specs run. A Cypress task calls the Synthesized REST API from Node, waits for the workflow to finish, and fails the hook if the data isn't ready. The access key never reaches the browser.

Cypress and Synthesized at a glance

There is no Cypress plugin; this pattern uses the documented REST API and Cypress's documented tasks.

Where the call goesA task registered in setupNodeEvents and called with cy.task from a before hook.
How it connectsNode's fetch starts the workflow and polls workflow_run_status until it is final.
ConfigurationGOVERNOR_URL, WORKFLOW_ID and GOVERNOR_ACCESS_KEY as environment variables of the Cypress process.
TimeoutsPass a timeout to cy.task; the default task timeout is 60 seconds.
StatusWorks through the REST API. Cypress isn't named in the Synthesized docs; the API calls are.

Set it up

1. Build the workflow in Governor

Create the masking, subsetting or generation workflow that fills your test database, and run it once by hand.

2. Provide the settings

Set GOVERNOR_URL, WORKFLOW_ID and GOVERNOR_ACCESS_KEY in the environment that starts Cypress.

3. Register the task

Add the synthesized:refresh task to cypress.config.js, as below.

4. Call it before the tests

Call the task from a before hook in the specs that need fresh data, with a timeout long enough for the workflow.

Example task

cypress.config.js

const { defineConfig } = require('cypress');
 
const api = `${process.env.GOVERNOR_URL}/external/api/v1`;
const headers = { 'X-Access-Key': process.env.GOVERNOR_ACCESS_KEY };
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
 
module.exports = defineConfig({
e2e: {
setupNodeEvents(on) {
on('task', {
async 'synthesized:refresh'() {
const start = await fetch(`${api}/workflow/${process.env.WORKFLOW_ID}/run`, { method: 'POST', headers });
if (!start.ok) throw new Error(`Run not started: HTTP ${start.status}`);
const { workflow_run_id } = await start.json();
for (;;) {
const res = await fetch(`${api}/workflow-run/${workflow_run_id}`, { headers });
if (!res.ok) throw new Error(`Status check failed: HTTP ${res.status}`);
const run = await res.json();
if (run.workflow_run_status === 'COMPLETED') return null;
if (['FAILED', 'STOPPED'].includes(run.workflow_run_status)) {
throw new Error(run.error_message || run.workflow_run_status);
}
await sleep(10000);
}
},
});
},
},
});

cypress/e2e/checkout.cy.js

describe('checkout', () => {
before(() => {
cy.task('synthesized:refresh', null, { timeout: 30 * 60 * 1000 });
});
 
it('pays with a saved card', () => {
// your test, running against freshly masked data
});
});

Things to know

Use a dedicated key

An access key carries the permissions of the Governor user who generated it. Create a user that can reach only the workflows this pipeline runs, generate the key as that user, and give it a short expiry: keys are chosen from 1 hour to a year, and the docs say they can't yet be revoked.

One output database per environment

Two runs can't write to the same output database at the same time. If parallel pipelines or branches need data, give each environment its own workflow or output database.

Where the data goes

Workers read the source, mask, subset or generate, and write the target. Database contents stay with the workers and aren't sent to Governor, which, like the pipeline, only sees run status, logs and configuration. Run Synthesized on-premises, including air-gapped, and the data never leaves your environment; it is also available as SaaS.

Questions about Cypress and Synthesized

Is there a Cypress plugin?

No. A Node task defined in setupNodeEvents calls the Synthesized REST API, so it works with any Cypress setup that can reach your Governor over HTTPS. You need an HTTP client (the example uses Node's built-in fetch), the Governor URL, a workflow ID and an access key.

Why cy.task rather than cy.request?

The task runs in the Cypress Node process, so the access key stays in Node's environment and never reaches the browser. It can also wait as long as the workflow takes.

Should I refresh before every test?

Cypress recommends resetting state before tests rather than after them. A full masking run takes minutes, so refresh once per run or per spec, and reset small fixtures per test.

My task times out after a minute. Why?

cy.task uses taskTimeout, 60 seconds by default. Pass a longer timeout to the call, as in the example.

What about parallel runs on several machines?

Each machine would start its own refresh. Refresh once in the CI pipeline before cypress run instead, and keep the task for local runs.

Try it on one spec

Bring one Cypress spec that depends on production-like data, and see Synthesized prepare it before the run.

Updated November 2026

All product names, including Cypress, are trademarks of their respective owners.