Reputation: 737
I'm trying to add some trace headers to requests we send (as part of our automated tests), to help with debugging. My hope was to use t.testRun.test.id
, so that we can link all requests back to the test... however I keep getting TypeError: Cannot read property 'test' of undefined
.
I'm using the global import of t
. Other than passing the test object (t
) to every function, is there a way I can access the testRun object?
To reproduce, just do
import { t } from 'testcafe';
fixture('<name>')
.page('<page>')
.beforeEach(async () => {
console.log(await t.testRun.test.id);
};
test('<name>', async () => {/*...*/});
Upvotes: 1
Views: 790
Reputation: 2348
You can get access to the test run info only from the t
object obtained from the test
or beforeEach/afterEach
hooks:
.beforeEach(async t => {
console.log(await t.testRun.test.id);
});
The globally imported t
object contains only available actions like click, typeText, etc.
Note that you use a non-public undocumented API at your own risk.
Upvotes: 1