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

Improve assert.throws() error in TAP reporter #1333

Closed
Krinkle opened this issue Dec 15, 2018 · 0 comments
Closed

Improve assert.throws() error in TAP reporter #1333

Krinkle opened this issue Dec 15, 2018 · 0 comments
Labels
Component: HTML Reporter Type: Bug Something isn't working right.
Milestone

Comments

@Krinkle
Copy link
Member

Krinkle commented Dec 15, 2018

Test case

QUnit.module( "Throws match", function() {
	QUnit.test( "bad", function( assert ) {
		assert.throws( function() {
			throw new Error( "Match me with a pattern" );
		}, /incorrect pattern/, "match error" );
	} );
} );

What actually happened?

TAP version 13
not ok 1 global failure
  ---
  message: "match error"
  severity: failed
  actual: {}
  expected: {}
@Krinkle Krinkle added Component: HTML Reporter Type: Bug Something isn't working right. labels Dec 15, 2018
Krinkle added a commit that referenced this issue Dec 15, 2018
Krinkle added a commit that referenced this issue Jan 3, 2019
Follows-up #1335, which was missing
the quotes on the tap-outputs key, and thus the unit test was seeing
expectedOutput[command] as `undefined`, which was then passed to
RegExp as `new RegExp(undefined)`, which produces /(?:)/, which is a
no-op that always matches, so re.test(output) === true.

Yay me for writing a useless test.

Ref #1333.
Krinkle added a commit that referenced this issue Jan 3, 2019
Report the `actual` (Error object) as a string.
And report an `expected` RegExp or Error object also in its
string form.

Currently, they were reported as their objects, which in the
generic js-reporters module was just printed as an empty object
without any properties because instances of RegExp and instances
of Error both have no own properties that are enumerable.

Fixes #1333.
Krinkle added a commit that referenced this issue Jan 3, 2019
Report the `actual` (Error object) as a string.
And report an `expected` RegExp or Error object also in its
string form.

Currently, they were reported as their objects, which in the
generic js-reporters module was just printed as an empty object
without any properties because instances of RegExp and instances
of Error both have no own properties that are enumerable.

Fixes #1333.
Krinkle added a commit that referenced this issue Jan 3, 2019
Report the `actual` (Error object) as a string.
And report an `expected` RegExp or Error object also in its
string form.

Currently, they were reported as their objects, which in the
generic js-reporters module was just printed as an empty object
without any properties because instances of RegExp and instances
of Error both have no own properties that are enumerable.

Also fix errorString() which oddly had logic for passing a plain
object, but didn't

Fixes #1333.
Krinkle added a commit that referenced this issue Jan 3, 2019
Follows-up #1335, which was missing
the quotes on the tap-outputs key, and thus the unit test was seeing
expectedOutput[command] as `undefined`, which was then passed to
RegExp as `new RegExp(undefined)`, which produces /(?:)/, which is a
no-op that always matches, so re.test(output) === true.

Yay me for writing a useless test.

Ref #1333.
Krinkle added a commit that referenced this issue Jan 3, 2019
Report the `actual` (Error object) as a string.
And report an `expected` RegExp or Error object also in its
string form.

Currently, they were reported as their objects, which in the
generic js-reporters module was just printed as an empty object
without any properties because instances of RegExp and instances
of Error both have no own properties that are enumerable.

Also fix errorString() which oddly had logic for passing a plain
object, but didn't

Fixes #1333.
@Krinkle Krinkle added this to the 2.9 milestone Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: HTML Reporter Type: Bug Something isn't working right.
Development

No branches or pull requests

1 participant