Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function showSuccess(stepName: string, stepLabel: StepLabel): void {
if (!t.ctx.stepRunnerContext) {
t.ctx.stepRunnerContext = {};
// eslint-disable-next-line no-console
console.log('');
}
// eslint-disable-next-line no-console
console.log(` ${chalk.green(symbols.ok)} ${stepLabel} ${stepName}`);
}
t.ctx.canExecute = true;
return;
}
if (targets.length === 0) {
return;
}
t.ctx.canExecute = false;
for (const target of targets) {
if (config.env.name === target) {
t.ctx.canExecute = true;
}
if (target === 'any') {
t.ctx.canExecute = true;
}
}
if (t.ctx.canExecute === false) {
const message = `next steps will not run because scenario is targeted only for ${targets}`;
// eslint-disable-next-line no-console
console.log(` ${chalk.inverse(message)}`);
}
},
};
only: async (...targets: TargetEnvironnement[]): Promise => {
const config: Config = getCurrentConfig(t);
if (config.env === undefined) {
throw new Error('The env property in the configuration file is not defined.');
}
if (config.env.name === 'any') {
// filters are bypassed if the environment in the configuration file is any
t.ctx.canExecute = true;
return;
}
if (targets.length === 0) {
return;
}
t.ctx.canExecute = false;
for (const target of targets) {
if (config.env.name === target) {
t.ctx.canExecute = true;
}
if (target === 'any') {
t.ctx.canExecute = true;
}
}
if (t.ctx.canExecute === false) {
const message = `next steps will not run because scenario is targeted only for ${targets}`;
// eslint-disable-next-line no-console
console.log(` ${chalk.inverse(message)}`);
}
},
};
const config: Config = getCurrentConfig(t);
if (config.env === undefined) {
throw new Error('The env property in the configuration file is not defined.');
}
if (config.env.name === 'any') {
// filters are bypassed if the environment in the configuration file is any
t.ctx.canExecute = true;
return;
}
if (targets.length === 0) {
return;
}
t.ctx.canExecute = false;
for (const target of targets) {
if (config.env.name === target) {
t.ctx.canExecute = true;
}
if (target === 'any') {
t.ctx.canExecute = true;
}
}
if (t.ctx.canExecute === false) {
const message = `next steps will not run because scenario is targeted only for ${targets}`;
// eslint-disable-next-line no-console
console.log(` ${chalk.inverse(message)}`);
}
},
};
function showSuccess(stepName: string, stepLabel: StepLabel): void {
if (!t.ctx.stepRunnerContext) {
t.ctx.stepRunnerContext = {};
// eslint-disable-next-line no-console
console.log('');
}
// eslint-disable-next-line no-console
console.log(` ${chalk.green(symbols.ok)} ${stepLabel} ${stepName}`);
}
export default async (): Promise => {
// get the config that was injected into the fixture/test context by the feature
const config: Config = getCurrentConfig(t);
// get the page object model that was injected in the context
const inputData = t.ctx.inputData as PageModel;
const value = inputData.name || '';
await t
.setTestSpeed(config.testSpeed)
.hover(selector.userNameInputBox)
.expect(selector.userNameInputBox.hasAttribute('disabled'))
.notOk()
.click(selector.userNameInputBox)
.typeText(selector.userNameInputBox, value, { replace: true })
.pressKey('tab');
};
export default async (stepName: string): Promise => {
// get the page object model that was injected in the context
const inputData = t.ctx.inputData as PageModel;
const config = getCurrentConfig(t);
// extract the message embedded in the step name
// by convention this value is prefixed and postfixed by a single quote
const message = firstMatch(/'.*'/g, stepName);
if (message === null) {
throw new Error(`Cannot extract message from the step name "${stepName}"`);
}
const myName = inputData.name || '';
await t
.expect(selector.resultContent.exists)
.ok({ timeout: config.timeout.longTimeout })
.expect(selector.resultContent.innerText)
.contains(message)
.expect(selector.resultContent.innerText)
export default async (stepName: string): Promise => {
// get the config that was injected into the fixture context by the feature
const config: Config = getCurrentConfig(t);
// get the page object model that was injected in the test context
const inputData = t.ctx.inputData as PageModel;
// extract the value embedded in the step name
// by convention this value is prefixed and postfixed by a single quote
const value = firstMatch(/'.*'/g, stepName);
if (value === null) {
throw new Error(`Cannot extract value from the step name "${stepName}"`);
}
// you may use the Visual Studio Code Extension Testcafe Snippets
// to help you write your tests
await t
.setTestSpeed(config.testSpeed)
.hover(selector.firstInputBox)
.expect(selector.firstInputBox.hasAttribute('disabled'))
.notOk({ timeout: config.timeout.longTimeout })