Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

After hook is being executed globally, when it shouldn't (?) #4070

Unanswered
clundstedt-m asked this question in Q&A
Discussion options

As of now we are having issues understanding how the After hook works, since we have 2 .steps.files, one being the common.steps.ts and other called home.steps.ts in which we have an After hook defined that simply waits for (5) seconds after each of the steps is executed.

Now if we run some tests that involve steps JUST from common_steps.ts and nothing from the home.steps.ts (where we have the After hook), the hook itself is being executed as if it were part of the first mentioned here, or more likely seemingly being executed globally as if it were defined in some kind of Global.steps.ts or something like that which is not the case.

Are we kinda getting the overall usage of the After hook? or it is intended that every After hook defined in any .steps file or any other test related script will be executed in each and every test from that point onward?

My home.steps.ts file looks something like this:

 import { TestData } from "@testinghouse/self-helpers"
 import { testrailFlags } from "../../services/Integration/functions/testrail.flags";
 const { I } = inject();
 Given("we update flags for users", async () => {
 let testData:TestData = await I.grabTestData()
 await testRailFlags.getTestRailConfig()
 await I.setFlag(testData["flagName"], testData["projectId"], testData["markedAsDone"]);
 })
 Then("we validate that the flags are marked as Done", async () => {
 let testData:TestData = await I.grabTestData()
 await I.verifyFlagValues(testData["flagName"], testData["projectId"])
 })
 After(() => {
 I.wait(5)
 })

And my common_steps, looks like this:

import { TestData } from "@testinghouse/self-helpers"
const {mobileHomePage, testRailServices, I} = inject();
import * as common_testrail_services from '../../services/Commons/common_testrail_services';
Given('that I successfully log in', async () => {
 let testData: TestData = await I.grabTestData()
 await login(testData.userID, testData.password)
 await testRailServices.storeAccessToken();
})
Then('the project list is generated', async () => {
 let testData: TestData = await I.grabTestData()
 await testRailServices.getProjectList()
 await testRailServices.sortByProjectID();
})
let login = async (userID: string, password: string) => {
 await testRailServices.doLogin()
}
export = {login}

And finally my test .feature file looks like this:

@mobile
Feature: TestRail Flag changes POC
Test programmatic flag changes
@testRail
Scenario: Flags are updated based on parameters
 Given that I successfully log in
 Then the project list is generated

And with this, even though no single step from the home.steps.ts is being used, the after hook for 5s is still being executed, which seems kinda off.

Hope that I was clear enough with my question and hopefully someone can shed some light on us about this behavior to know how to re-route our efforts having that in mind.

Best Regards and thanks!

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /