Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 (): Promise => {
// get the config that was injected into the fixture/test context by the feature
const config: Config = getCurrentConfig(t);
await t
.setTestSpeed(config.testSpeed)
.hover(selector.submitButton)
.expect(selector.submitButton.hasAttribute('disabled'))
.notOk({ timeout: config.timeout.longTimeout })
.click(selector.submitButton);
};
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 })
.typeText(selector.firstInputBox, value, { replace: true })
.pressKey('tab');
if (inputData.name) {
await t
.setTestSpeed(config.testSpeed)
.hover(selector.secondInputBox)
.expect(selector.secondInputBox.hasAttribute('disabled'))
.notOk({ timeout: config.timeout.longTimeout })
.typeText(selector.secondInputBox, inputData.name, { replace: true })
.pressKey('tab');
}
const config: IConfig = getCurrentConfig(t);
// get the page object model that was injected in the test context
const inputData = t.ctx.inputData as IPageModel;
// 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 })
.typeText(selector.firstInputBox, value, { replace: true })
.pressKey('tab');
if (inputData.name) {
await t
.setTestSpeed(config.testSpeed)
.hover(selector.secondInputBox)
.expect(selector.secondInputBox.hasAttribute('disabled'))
.notOk({ timeout: config.timeout.longTimeout })
.typeText(selector.secondInputBox, inputData.name, { replace: true })
.pressKey('tab');
}