-
Notifications
You must be signed in to change notification settings - Fork 781
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
QUnit.module.only
behaves strange
#1272
Comments
Thanks for the report + reproduction! Definitely a bug and likely just a combination we didn't test (I think all the tests use the module callback form). |
Hi, I did some analysis and what I came with is the following: we can flag the current module (which is the one we attach In summary, here is the diff: `src/core.js`diff --git a/src/core.js b/src/core.js
index b2e9472..95230e5 100644
--- a/src/core.js
+++ b/src/core.js
@@ -115,6 +115,10 @@ function processModule( name, options, executeNow, modifiers = {} ) {
// TODO: extract this to a new file alongside its related functions
function module( name, options, executeNow ) {
if ( focused ) {
+ if ( !config.currentModule.focused ) {
+ config.currentModule.focused = true;
+ }
+
return;
}
@@ -130,6 +134,10 @@ function module( name, options, executeNow ) {
module.only = function() {
if ( focused ) {
+ if ( !config.currentModule.focused ) {
+ config.currentModule.focused = true;
+ }
+
return;
}
@@ -143,6 +151,10 @@ module.only = function() {
module.skip = function( name, options, executeNow ) {
if ( focused ) {
+ if ( !config.currentModule.focused ) {
+ config.currentModule.focused = true;
+ }
+
return;
}
@@ -158,6 +170,10 @@ module.skip = function( name, options, executeNow ) {
module.todo = function( name, options, executeNow ) {
if ( focused ) {
+ if ( !config.currentModule.focused ) {
+ config.currentModule.focused = true;
+ }
+
return;
} `src/test.js`diff --git a/src/test.js b/src/test.js
index 097fd39..e5ab69a 100644
--- a/src/test.js
+++ b/src/test.js
@@ -658,7 +658,7 @@ function checkPollution() {
// Will be exposed as QUnit.test
export function test( testName, callback ) {
- if ( focused ) {
+ if ( focused || config.currentModule.focused ) {
return;
}
@@ -671,7 +671,7 @@ export function test( testName, callback ) {
}
export function todo( testName, callback ) {
- if ( focused ) {
+ if ( focused || config.currentModule.focused ) {
return;
}
@@ -686,7 +686,7 @@ export function todo( testName, callback ) {
// Will be exposed as QUnit.skip
export function skip( testName ) {
- if ( focused ) {
+ if ( focused || config.currentModule.focused ) {
return;
}
@@ -700,7 +700,7 @@ export function skip( testName ) {
// Will be exposed as QUnit.only
export function only( testName, callback ) {
- if ( focused ) {
+ if ( focused || config.currentModule.focused ) {
return;
} If this solution looks good, I'll be happy to open a PR. |
Resolved with #1436? |
Just tested with latest version and it doesn't seem to be fixed. See https://plnkr.co/edit/lLBZUFu7opjXpTVq?preview |
This bug affected use of QUnit.module.only when used in a "flat" way, e.g. without scoping. For the following, it resulted in running test 1A and 2A, instead of only 1A: ``` QUnit.module.only( "Module one" ); QUnit.test( "1A", assert => { assert.ok( true ); } ); QUnit.module( "Module two" ); QUnit.test( "2A", assert => { assert.ok( false ); } ); ``` Also move the "only" tests to CLI suite to verify TAP output (more stable than `QUnit.done` post-run hack in HTML). Fixes #1272.
QUnit.module.only
behaves strange when using the module syntax that assigns tests to modules using the order of invocation, e.g.:Without
only
test in module 1
belongs tomodule 1
andtest in module 2
belongs tomodule 2
. Usingonly
inmodule 1
the second test also seems to belong tomodule 1
and is run (applying the wrong hooks if there would be any).You can check this in this plunk: https://embed.plnkr.co/mh4VgJ0O6Dhp4H5APd3S/
The text was updated successfully, but these errors were encountered: