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

Core: Warn when hooks from a different module are invoked #1586

Merged

Conversation

raycohen
Copy link
Member

@raycohen raycohen commented Apr 10, 2021

Ref: #1576

Updated with test coverage via cli test.

@Krinkle
Copy link
Member

Krinkle commented Apr 10, 2021

Perhaps a CLI test could work:

$ cat test/cli/fixtures/single.js
QUnit.module( "Single", function() {
	QUnit.test( "has a test", function( assert ) {
		assert.push( true, 1, 1, "message here" );
	} );
} );

$ bin/qunit.js test/cli/fixtures/single.js 
TAP version 13
assert.push is deprecated and will be removed in QUnit 3.0. Please use assert.pushResult instead (https://api.qunitjs.com/assert/pushResult).
ok 1 Single > has a test
1..1
# pass 1
# skip 0
# todo 0
# fail 0

(That does remind me, this probably isn't valid TAP output...)

@Krinkle Krinkle added this to the 2.x release milestone Apr 10, 2021
@Krinkle
Copy link
Member

Krinkle commented Apr 10, 2021

(That does remind me, this probably isn't valid TAP output...)

Taking a closer look, I think we're fine here actually. On the CLI, tap parsers consume stdout. In the browser, tap parser consume console.log. Our warnings go use console.warn() which means we're definitely fine in-browser, and on CLI this is channeled by Node.js to stderr rather than stdout, so we should be fine there as well.

$ bin/qunit.js test/cli/fixtures/single.js >/dev/null
assert.push is deprecated and will be removed in QUnit 3.0. Please use assert.pushResult instead (https://api.qunitjs.com/assert/pushResult).
$ bin/qunit.js test/cli/fixtures/single.js 2>/dev/null
TAP version 13
ok 1 Single > has a test
1..1
# pass 1
# skip 0
# todo 0
# fail 0

Anyway, so much for that sidebar. Carry on!

@raycohen raycohen marked this pull request as draft April 10, 2021 20:22
@raycohen raycohen marked this pull request as ready for review April 10, 2021 21:54
@Krinkle Krinkle merged commit f9ce52b into qunitjs:main Apr 10, 2021
@raycohen raycohen deleted the warn-when-hooks-referenced-in-wrong-module branch April 11, 2021 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants