Hooks
Autometa supports the following hooks: Setup, Before, After, Teardown.
Setup will be run before any scenarios. Teardown will be run after all
scenarios.
Before will run before each scenario, and After runs after each scenario.
Both Before and After recieve a copy of the App if it's defined.
The App argument in Before and Each will be the same as the one used
by the Scenario that triggered them.
import { Setup, Before, After, Teardown } from "@autometa/cucumber-runner";
Setup(() => console.log("setting up"));
// optional description (availabbe to all hooks)
Setup("Set up the foo data", () => console.log("setting up"));
Before(async ({ apiClient }: App) => {
await apiClient.setupTestData();
});
After(async ({ apiClient }: App) => {
await apiClient.cleanupTestData();
});
TearDown(() => console.log("exiting"));
Like Steps, Hooks can be scoped. If a Hook is defined inside a Feature callback,
it will only execute before tests in that feature. If a rule, only tests in that rule.
If a scenario outline, only the scenarios generated by that outline etc.
Feature(() => {
Before("run only for these tests", () => {});
}, "./my-feature.ts");