Skip to main content
Version: 9.0.0

Hooks

Hooks allow you to pull complex behaviors out of your Features into succinct, composable functions. This makes testing Features behavior potentially much easier.

A very good example is when we have an application that requires a Login and Logoff steps every time we run a feature. Well, say we have 100 Features, this means we will write the code for those steps 100 times! That is not right, this is why we use Hooks, so we can easily abstract those steps into one single location that can be reused in all features.

Test Maker Hooks

Test Maker always Aims to make your Testing simple, elegant and more organized. Therefore, we implemented multiple hooks for you that cover all scenarios for abstracting code.

Test Maker hooks are split into two types:

Global: Which applies for all your Features, Scenarios or Steps/ Those hooks that we cover in this section are defined in the Configuration file.

Local: Which is per Feature, Scenario or Step. Those hooks are not covered in this section since they are defined in the Feature File section.

Options

NameTypeDescription
beforeAllfunctionYou can perform some actions before beginning your test execution
beforeEachFeaturefunctionYou can perform some actions before each feature of your test execution
beforeEachScenariofunctionYou can perform some actions before each scenario of each of your features
beforeEachStepfunctionYou can perform some actions before each steps of each of your scenarios
afterEachStepfunctionYou can perform some actions after each steps of each of your scenarios
afterEachScenariofunctionYou can perform some actions after each scenario of each of your features
afterEachFeaturefunctionYou can perform some actions after each feature of your test execution
afterAllfunctionYou can perform some actions after beginning your test execution

Basic Usage

    hooks: {
beforeEachScenario:(async (I:Controller) => {
await I.fillField(`#usernameSelector`, `myUsername`);
await I.fillField(`#passwordSelector`, `myPassword`);
await I.click(`#login`);
}),
}