-
Notifications
You must be signed in to change notification settings - Fork 675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to testRunInfo in testRun before and after hooks #8106
Comments
Hello @codambro, What information do you expect to retrieve from Please describe your usage scenario in greater detail. There might already be an existing functionality or workaround in TestCafe that aligns with your scenario. |
Hello. Yeah I think I realized testRunInfo may not even have what I need. I'm defining a global testRun.before hook that sets something up for specific tests to use. But it takes a long time to run. So I only want to set it up if one or more of the specific tests is being executed in the testRun. Ideally in testRun.before I can determine which exact tests are part of the run, including with respect to .meta filtering, along with .skip and .only modifiers. |
Perhaps, this workaround can solve the issue or allow you to create your own solution: module.exports = {
hooks: {
test: {
before: async t => {
const testfile = t.testRun.test.testFile;
}
},
},
}; From the
However, It's not part of our public API and can be changed at any time. Please use it with caution. |
Thanks for the suggestion. Unfortunately it wouldn't help since I need the information at the start of the testRun and not at the start of each individual fixture. |
We can consider your enhancement request, but we need to understand if this enhancement has practical application. Please describe how it should work and provide a detailed example of how this enhancement would be applied in practice. |
Found a sufficient workaround. Sharing in case others have similar issues. I'm using the createRunner API with a filter function. In there, I'm tracking what tests would run.
Then my testRun hook functions can call that in testcaferc.js:
I believe the |
What is your Scenario?
I would like to access the
testRun
object within the testRun before/after hooks. My specific use case is I have some setup that only needs to be run if certain test fixtures are executed, and I need the testRun info to be able to determine what fixtures are run.What are you suggesting?
the
fixture.before
global hook takes two arguments:async (ctx, fixtureInfo) => {}
But the
testRun.before
global hook only takes 1:async ctx => {}
I believe the testRun before hook should be the same as the fixture level hooks:
async (ctx, testRunInfo) => {}
What alternatives have you considered?
Parsing command line args
Additional context
Realize I don't know exactly where in
testRunInfo
the tests would be or if that info even existsThe text was updated successfully, but these errors were encountered: