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

Assertion.contains() requires same type as actual parameter in expect() #3537

Closed
timnederhoff opened this issue Mar 6, 2019 · 3 comments
Closed
Labels
AREA: server AREA: TypeScript definitions STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: API TYPE: bug The described behavior is considered as wrong (bug).
Milestone

Comments

@timnederhoff
Copy link
Contributor

timnederhoff commented Mar 6, 2019

What is your Test Scenario?

To have this test code to compile:

test('string array contains string', async t => {
  await t.expect(['one', 'two', 'three']).contains('one');
});

test('number array contains number', async t => {
  await t.expect([1, 2, 3]).contains(3);
});

test('object contains object', async t => {
  await t.expect({ key1: 'val1', key2: 'val2' }).contains({ key1: 'val1' } as any);
});

What is the Current behavior?

Error: TypeScript compilation failed.
/my/test.ts (6, 52): Argument of type '"one"' is not assignable to parameter of type 'string[]'.
/my/test.ts (10, 38): Argument of type '3' is not assignable to parameter of type 'number[]'.
/my/test.ts (14, 59): Argument of type '{ key1: string; }' is not assignable to parameter of type '{ key1: string; key2: string; }'.
  Property 'key2' is missing in type '{ key1: string; }' but required in type '{ key1: string; key2: string; }'.

What is the Expected behavior?

Testcafe compiles the typescript and runs the tests and passes them.

Note: Using Javascript, the test runs successfully. defining expected values types as any will pass the compilation of the typescript:

test('string array contains string', async t => {
  await t.expect(['one', 'two', 'three']).contains('one' as any);
});

test('number array contains number', async t => {
  await t.expect([1, 2, 3]).contains(3 as any);
});

test('object contains object', async t => {
  await t.expect({ key1: 'val1', key2: 'val2' }).contains({ key1: 'val1' } as any);
});

Your Environment details:

  • testcafe version: 1.1.0
  • node.js version: v10.15.1
  • command-line arguments: testcafe chrome /my/test.ts
  • platform and version: Linux Ubuntu 16.04
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Mar 6, 2019
@AndreyBelym AndreyBelym added TYPE: bug The described behavior is considered as wrong (bug). SYSTEM: API AREA: server AREA: TypeScript definitions labels Mar 6, 2019
@AndreyBelym AndreyBelym added this to the Sprint #29 milestone Mar 6, 2019
@AndreyBelym
Copy link
Contributor

Thank you for reporting this problem. We will fix it in the current development sprint.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 6, 2019
@timnederhoff
Copy link
Contributor Author

awesome, thanks!

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Mar 11, 2019
@Farfurix Farfurix removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 11, 2019
@lock
Copy link

lock bot commented Mar 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 27, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AREA: server AREA: TypeScript definitions STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: API TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

3 participants