Cypress
Cypress Integration
Q: How do I integrate Stoobly with Cypress tests?
import Stoobly from 'stoobly';
import { RecordPolicy, RecordOrder, RecordStrategy } from 'stoobly/constants';
const stoobly = new Stoobly();
const interceptor = stoobly.cypressInterceptor({
urls: [new RegExp('https://api.example.com/.*')],
});
describe('My Tests', () => {
// Use function() form to access Mocha context
beforeEach(function () {
// Derive hierarchical scenario name from the test path
const scenarioName = this.test.titlePath().join(' > ');
interceptor.withScenarioName(scenarioName);
// Enable interceptor in beforeEach
interceptor.enable();
});
it('can fetch data', () => {
cy.visit('https://example.com');
// Your test code here
});
});Q: Why must I call enable() in beforeEach for Cypress?
Q: How do I record requests in Cypress tests?
Q: What's the warning about synchronous requests in Cypress?
Last updated