2020-01-15 00:15:14 +02:00
|
|
|
export const before = (taskResult, options, backend) => {
|
2019-12-18 18:16:02 +02:00
|
|
|
Cypress.config('taskTimeout', 7 * 60 * 1000);
|
2019-10-22 19:59:13 +03:00
|
|
|
cy.task('setupBackend', { backend, options }).then(data => {
|
|
|
|
taskResult.data = data;
|
|
|
|
Cypress.config('defaultCommandTimeout', data.mockResponses ? 5 * 1000 : 1 * 60 * 1000);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-01-15 00:15:14 +02:00
|
|
|
export const after = (taskResult, backend) => {
|
2019-10-22 19:59:13 +03:00
|
|
|
cy.task('teardownBackend', {
|
|
|
|
backend,
|
|
|
|
...taskResult.data,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-01-15 00:15:14 +02:00
|
|
|
export const beforeEach = (taskResult, backend) => {
|
2019-10-22 19:59:13 +03:00
|
|
|
const spec = Cypress.mocha.getRunner().suite.ctx.currentTest.parent.title;
|
|
|
|
const testName = Cypress.mocha.getRunner().suite.ctx.currentTest.title;
|
|
|
|
cy.task('setupBackendTest', {
|
|
|
|
backend,
|
|
|
|
...taskResult.data,
|
|
|
|
spec,
|
|
|
|
testName,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (taskResult.data.mockResponses) {
|
|
|
|
const fixture = `${spec}__${testName}.json`;
|
|
|
|
console.log('loading fixture:', fixture);
|
|
|
|
cy.stubFetch({ fixture });
|
|
|
|
}
|
|
|
|
|
|
|
|
return cy.clock(0, ['Date']);
|
|
|
|
};
|
|
|
|
|
2020-01-15 00:15:14 +02:00
|
|
|
export const afterEach = (taskResult, backend) => {
|
2019-10-22 19:59:13 +03:00
|
|
|
const spec = Cypress.mocha.getRunner().suite.ctx.currentTest.parent.title;
|
|
|
|
const testName = Cypress.mocha.getRunner().suite.ctx.currentTest.title;
|
|
|
|
|
|
|
|
cy.task('teardownBackendTest', {
|
|
|
|
backend,
|
|
|
|
...taskResult.data,
|
|
|
|
spec,
|
|
|
|
testName,
|
|
|
|
});
|
|
|
|
|
2020-01-15 00:15:14 +02:00
|
|
|
if (
|
|
|
|
!process.env.RECORD_FIXTURES &&
|
|
|
|
Cypress.mocha.getRunner().suite.ctx.currentTest.state === 'failed'
|
|
|
|
) {
|
2019-10-22 19:59:13 +03:00
|
|
|
Cypress.runner.stop();
|
|
|
|
}
|
|
|
|
};
|
2020-02-24 23:44:10 +01:00
|
|
|
|
|
|
|
export const seedRepo = (taskResult, backend) => {
|
|
|
|
cy.task('seedRepo', {
|
|
|
|
backend,
|
|
|
|
...taskResult.data,
|
|
|
|
});
|
|
|
|
};
|