testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Typescript: allow strict typing of test and fixture `meta` and `ctx`

Open andrzej-woof opened this issue 3 years ago • 1 comments

What is your Scenario?

I want to have strict type definition for meta object in order to set some properties only within given type boundaries and get utilize IDE suggestions to ease up writing test code For example:

fixture('Fixture');

test('Test', async () => {}).meta({ target: 'staging' });

I want to enforce the type target: 'staging' | 'local';

In addition I'd suggest similar for test/fixture ctx object as I'm setting some shared context properties in before hook

What are you suggesting?

I'm not sure what would be the best way to achieve that Maybe expose generic meta<T>(data: T) functions No clue about best approach for ctx

What alternatives have you considered?

I have to cast everywhere to benefit from static checks and suggestions

Additional context

No response

andrzej-woof avatar Apr 22 '22 16:04 andrzej-woof

@andrzej-kodify Thank you for the suggestion.

felis2803 avatar Apr 26 '22 11:04 felis2803