qunit icon indicating copy to clipboard operation
qunit copied to clipboard

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

Open Krinkle opened this issue 9 months ago • 0 comments

Follows-up https://github.com/qunitjs/qunit/issues/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 did you expect to happen?

For simple cases like this, it would be valuable I think if we can let values serve dual-purpose as the test name suffix. In other words as:

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

What actually happened?

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

Krinkle avatar Nov 09 '23 19:11 Krinkle