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: Connected to #1434: run all only tests #1436

Merged
merged 3 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,12 @@ export default function module( name, options, executeNow ) {
}

module.only = function() {
if ( focused ) {
return;
if ( !focused ) {
config.modules.length = 0;
config.queue.length = 0;
}

config.modules.length = 0;
config.queue.length = 0;

module( ...arguments );
processModule( ...arguments );

focused = true;
};
Expand Down
8 changes: 3 additions & 5 deletions src/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,13 +719,11 @@ export function skip( testName ) {

// Will be exposed as QUnit.only
export function only( testName, callback ) {
if ( focused ) {
return;
if ( !focused ) {
config.queue.length = 0;
focused = true;
}

config.queue.length = 0;
focused = true;

const newTest = new Test( {
testName: testName,
callback: callback
Expand Down
10 changes: 10 additions & 0 deletions test/module-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ QUnit.done( function() {
"75e1bf3f": {
skipped: false,
todo: false
},
"c7ae85c2": {
skipped: false,
todo: false
}
} );
} );
Expand Down Expand Up @@ -79,3 +83,9 @@ QUnit.module( "module C", function() {
assert.ok( false, "this test should not run" );
} );
} );

QUnit.module.only( "module D", function() {
QUnit.test( "test D", function( assert ) {
assert.ok( true, "this test should run as well" );
} );
} );
32 changes: 20 additions & 12 deletions test/only.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
QUnit.module( "QUnit.only" );
QUnit.module( "QUnit.only", function( hooks ) {
let testsRun = 0;

QUnit.test( "implicitly skipped test", function( assert ) {
assert.ok( false, "test should be skipped" );
} );
hooks.after( function( assert ) {
assert.strictEqual( testsRun, 2 );
} );

QUnit.only( "only run this test", function( assert ) {
assert.ok( true, "only this test should run" );
} );
QUnit.test( "implicitly skipped test", function( assert ) {
assert.ok( false, "test should be skipped" );
} );

QUnit.test( "another implicitly skipped test", function( assert ) {
assert.ok( false, "test should be skipped" );
} );
QUnit.only( "run this test", function( assert ) {
testsRun += 1;
assert.ok( true, "only this test should run" );
} );

QUnit.test( "another implicitly skipped test", function( assert ) {
assert.ok( false, "test should be skipped" );
} );

QUnit.only( "ignore the subsequent calls to only", function( assert ) {
assert.ok( false, "this test should be skipped" );
QUnit.only( "all tests with only run", function( assert ) {
testsRun += 1;
assert.ok( true, "this test should run as well" );
} );
} );