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

Let simple array data in test.each() serve as automatic labels #1733

Closed
Krinkle opened this issue Nov 9, 2023 · 0 comments · Fixed by #1799
Closed

Let simple array data in test.each() serve as automatic labels #1733

Krinkle opened this issue Nov 9, 2023 · 0 comments · Fixed by #1799
Assignees
Labels
Component: Core For module, test, hooks, and reporters. Type: Enhancement New idea or feature request.
Milestone

Comments

@Krinkle
Copy link
Member

Krinkle commented Nov 9, 2023

Follows-up #1568

What are you trying to do?

Code that reproduces the problem:

QUnit.test.each( 'escapeRegExp [specials]', [
	'foo',
	'bar',
	'_',
	'+',
	'-',
	'^',
	'$'
], function ( assert, str ) {
	assert.propEqual(
		str.match( new RegExp( mw.util.escapeRegExp( str ) ) ),
		[ str ],
		'confirm correct escaping by being able to match itself'
	);
} );
Screenshot

What actually happened?

  • mytest [0]
  • mytest [1]
  • mytest [2].

What did you expect to happen?

For simple cases like this, it would be valuable if we let values serve as the test case label. In other words as:

  • mytest [foo]
  • mytest [bar]
  • mytest [_]

Example

EDIT: Example based on the implementation at #1799.

Before

TAP version 13
ok 1 array of strings [0]
ok 2 array of strings [1]
ok 3 array of strings [2]
ok 4 array of strings [3]

ok 13 array of mixed [0]
ok 14 array of mixed [1]
ok 15 array of mixed [2]
ok 16 array of mixed [3]
ok 17 array of mixed [4]
ok 18 array of mixed [5]
ok 19 array of mixed [6]
ok 20 array of mixed [7]
ok 21 array of mixed [8]
ok 22 array of mixed [9]
ok 23 array of mixed [10]

ok 27 keyed objects [caseFoo]
ok 28 keyed objects [caseBar]

After

TAP version 13
ok 1 array of strings [foo]
ok 2 array of strings [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
ok 3 array of strings [$]
ok 4 array of strings [http://example.org]

ok 13 array of mixed [0: undefined]
ok 14 array of mixed [1: null]
ok 15 array of mixed [2: false]
ok 16 array of mixed [3: true]
ok 17 array of mixed [4: 0]
ok 18 array of mixed [5: 1]
ok 19 array of mixed [6: -10]
ok 20 array of mixed [7: 3.3333333333333335]
ok 21 array of mixed [8: 1e+43]
ok 22 array of mixed [9: Infinity]
ok 23 array of mixed [10: NaN]

ok 27 keyed objects [caseFoo]
ok 28 keyed objects [caseBar]
@Krinkle Krinkle added Type: Enhancement New idea or feature request. Component: Core For module, test, hooks, and reporters. help welcome good first issue Straight-forward to start and receive help with. labels Nov 9, 2023
@Krinkle Krinkle added this to the 3.0 release milestone Jun 18, 2024
@Krinkle Krinkle self-assigned this Sep 5, 2024
@Krinkle Krinkle removed help welcome good first issue Straight-forward to start and receive help with. labels Sep 5, 2024
Krinkle added a commit that referenced this issue Sep 7, 2024
Fixes #1733.

Co-authored-by: Vivien Tintillier <vtintillier.privatedev@gmail.com>
@Krinkle Krinkle closed this as completed in bf42d2b Sep 8, 2024
Krinkle added a commit that referenced this issue Dec 2, 2024
@Krinkle Krinkle modified the milestones: 3.0 release, 2.x release Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core For module, test, hooks, and reporters. Type: Enhancement New idea or feature request.
Development

Successfully merging a pull request may close this issue.

1 participant