/** * Dynamically injects dependencies, see https://codecept.io/pageobjects/#dynamic-injection * @param {*} dependencies */ injectDependencies(dependencies) { this.scenarios.forEach(scenario => scenario.injectDependencies(dependencies)); return this; }
dataScenarioConfig.scenarios.forEach((scenario) => { scenario.test.tags.should.include('@user'); }); dataScenarioConfig.scenarios.forEach(scenario => should.equal(3, scenario.test._timeout)); }); dataScenarioConfig.scenarios.forEach(scenario => should.equal(3, scenario.test._retries)); }); dataScenarioConfig.scenarios.forEach(scenario => should.exist(scenario.test.throws)); }); dataScenarioConfig.scenarios.forEach(scenario => should.equal(err, scenario.test.throws)); }); dataScenarioConfig.scenarios.forEach(scenario => should.equal(helper, scenario.test.config[helperName])); }); ]; const dataScenarioConfig = context.Data(data).Scenario('scenario', () => {}); should.equal('scenario | test case title', dataScenarioConfig.scenarios[0].test.title); }); const data = [{ name: 'John Do' }]; const dataScenarioConfig = context.Data(data).Scenario('scenario', () => {}); should.equal(`scenario | ${JSON.stringify(data[0])}`, dataScenarioConfig.scenarios[0].test.title); }); });
/** * Declares that test should fail. * If test passes - throws an error. * Can pass an Error object or regex matching expected message. * */ fails() { this.scenarios.forEach(scenario => scenario.fails()); return this; }
/** * Retry this test for x times * * @param {*} retries */ retry(retries) { this.scenarios.forEach(scenario => scenario.retry(retries)); return this; }
/** * Configures a helper. * Helper name can be omitted and values will be applied to first helper. */ config(helper, obj) { this.scenarios.forEach(scenario => scenario.config(helper, obj)); return this; }
/** * Declares that test throws error. * Can pass an Error object or regex matching expected message. * * @param {*} err */ throws(err) { this.scenarios.forEach(scenario => scenario.throws(err)); return this; }
/** * Append a tag name to scenario title * @param {*} tagName */ tag(tagName) { this.scenarios.forEach(scenario => scenario.tag(tagName)); return this; }
/** * Set timeout for this test * @param {*} timeout */ timeout(timeout) { this.scenarios.forEach(scenario => scenario.timeout(timeout)); return this; }
data.reduce((acc, cur) => { acc.latencyGraph = mergeSortedArraysByStartTime(acc.latencyGraph, cur.latencyGraph); acc.latencyGraphKeys = acc.latencyGraphKeys.concat(cur.latencyGraphKeys); acc.errorsCodeGraph = mergeSortedArraysByStartTime(acc.errorsCodeGraph, cur.errorsCodeGraph); acc.errorsCodeGraphKeys = acc.errorsCodeGraphKeys.concat(cur.errorsCodeGraphKeys); acc.rps = mergeSortedArraysByStartTime(acc.rps, cur.rps); acc.rpsKeys = acc.rpsKeys.concat(cur.rpsKeys); acc.errorsBar = mergeArrayOfObjectsPropsByParameter(acc.errorsBar, cur.errorsBar, 'name'); acc.errorsBarKeys = acc.errorsBarKeys.concat(cur.errorsBarKeys); acc.scenarios = acc.scenarios.concat(cur.scenarios); return acc; }, initial)
createExpiredAt(scenario, params = {}) { let scenarioConfig = this.config.scenarios[scenario]; if (!scenarioConfig) { scenarioConfig = this.config.scenarios.default; } scenarioConfig = { ...scenarioConfig, ...params, }; const time = scenarioConfig.time || 60 * 60 * 1000; return new Date(Date.now() + time); }
function extractDslRootData(rawData) { const dslData = {}; const rowDataObject = JSON.parse(rawData); if (rowDataObject.type === DSL_TYPE){ dslData.scenarios = rowDataObject.scenarios; dslData.before = rowDataObject.before; } return dslData; }
deleteScenario(scenarioId){ ApiService.deleteScenarios(scenarioId) .then(res => { this.setState({messgae : 'User Deleted Successfully.'}); this.setState({scenarios: this.state.scenarios.filter(scenario => scenario.id !== scenarioId)}); }) }
/** * Pass in additional objects to inject into test * @param {*} obj */ inject(obj) { this.scenarios.forEach(scenario => scenario.inject(obj)); return this; }
genCode(scenario, params = {}) { let scenarioConfig = this.config.scenarios[scenario]; if (!scenarioConfig) { scenarioConfig = this.config.scenarios.default; } scenarioConfig = { ...scenarioConfig, ...params, }; if (scenarioConfig.uniq) return this.generateUniqCode(scenarioConfig); return this.generateCode(scenarioConfig); }
data.reduce((acc, cur) => { acc.latencyGraph = mergeSortedArraysByStartTime(acc.latencyGraph, cur.latencyGraph); acc.latencyGraphKeys = acc.latencyGraphKeys.concat(cur.latencyGraphKeys); acc.errorsCodeGraph = mergeSortedArraysByStartTime(acc.errorsCodeGraph, cur.errorsCodeGraph); acc.errorsCodeGraphKeys = acc.errorsCodeGraphKeys.concat(cur.errorsCodeGraphKeys); acc.rps = mergeSortedArraysByStartTime(acc.rps, cur.rps); acc.rpsKeys = acc.rpsKeys.concat(cur.rpsKeys); acc.errorsBar = mergeArrayOfObjectsPropsByParameter(acc.errorsBar, cur.errorsBar, 'name'); acc.errorsBarKeys = acc.errorsBarKeys.concat(cur.errorsBarKeys); acc.scenarios = acc.scenarios.concat(cur.scenarios); return acc; }, initial)