Search code examples
testingautomated-testse2e-testingtestcafeweb-testing

Access the name of the current fixture and test at runtime


For usage as in

test(testName, async (t) => {
  const ua = await getUA()

  await t.takeScreenshot(
    fixtureName +
      "/" +
      testName +
      "/" +
      identifyUserAgent(ua) +
      "/" +
      "scsh_1.png",
  )
...

As of testcafe@0.21.1 my workaround is

const fixtureName = "Index_Page_Test"

fixture(fixtureName).page(...)

...

const testName = "dom_has_critical_elements"

test(testName, async (t) => {
...

but would prefer to have it available on t. Am i missing something?


Solution

  • At preset, t does not contain the test and fixtures names. For your purpose (build path for takeScreenshot action) you can use the custom screenshot pattern feature.