Skip to content
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

[docs] add documentation for API usage of userVariables #7896

Open
htho opened this issue Jul 24, 2023 · 1 comment
Open

[docs] add documentation for API usage of userVariables #7896

htho opened this issue Jul 24, 2023 · 1 comment
Labels
AREA: docs An issue related to the product documentation. TYPE: enhancement The accepted proposal for future implementation.

Comments

@htho
Copy link
Contributor

htho commented Jul 24, 2023

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

@htho htho added the TYPE: enhancement The accepted proposal for future implementation. label Jul 24, 2023
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jul 24, 2023
@Aleksey28
Copy link
Collaborator

Hi @htho,

Thank you for informing us about this issue. We'll investigate it and update this thread once we have news.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jul 25, 2023
@Aleksey28 Aleksey28 added AREA: docs An issue related to the product documentation. STATE: Need response An issue that requires a response or attention from the team. and removed STATE: Need response An issue that requires a response or attention from the team. labels Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AREA: docs An issue related to the product documentation. TYPE: enhancement The accepted proposal for future implementation.
Projects
None yet
Development

No branches or pull requests

2 participants