mercredi 17 février 2021

Access the TestCafe `t.testRun` data, using a global import of the test object

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 () => {/*...*/});

Aucun commentaire:

Enregistrer un commentaire