DevExpress / DevExpress/testcafe

[docs] add documentation for API usage of userVariables

Open
#7,896 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

AREA: docs TYPE: enhancement
Dominant language
JavaScript
Stars
9.9k
Forks
676
PR merge metrics
No merged PRs in 30d

Description

What is your Scenario?

I was looking for a way to inject userVariables (introduced in v1.16.0) when I start TestCafe via the js API.
The only documented way to use them is via a configuration file.
I did not find any documentation about JS API usage, but this comment by @Artem-Babich in #2431:

Hi, you can use userVariables to pass additional data to the tests. You can define them in the configuration file as well as in your runner code:

createTestCafe({userVariables: { url: 'test' }})
import { userVariables } from 'testcafe';

fixture `Test user variables`

test('Type text', async t => {
    await t.expect(userVariables.url).eql('test')
});

This is exactly what I was looking for.
It works, although it is a little awkward because all other configuration goes to the runner (and therefore RunOptions).

What are you suggesting?

For API / TestCafe API / Global / createTestCafe() # options

  1. Add the paramter to the table of parameters
  2. Link to userVariables at "Related configuration file properties"

For API / Configuration File # User Variables

  1. Add:

CLI: N/A
API: createTestCafe

For /ts-defs-src/runner-api/configuration.d.ts

  1. Add userVariables: UserVariables
What alternatives have you considered?

I can add a file like testcafe.global.tc.ts:

declare module "testcafe" {
    global {
        interface TestCafeConfigurationOptions {
            userVariables: UserVariables
        }
    }
}
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the createTestCafe() options page, the Configuration File User Variables section, and ts-defs-src/runner-api/configuration.d.ts. Add the requested API references and userVariables type entry, then verify the documentation and TypeScript declaration describe the same supported usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.