Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 0626963

Browse files
Henk van den Brinkjuliemr
Henk van den Brink
authored andcommitted
feat(config): Option to exclude test for specific capability
Add the option to exclude spec files for a specific capability. This way you can ignore spec files for one capability only. For example if the test is known to fail in the capability. Closes #1230
1 parent 84bbbba commit 0626963

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

docs/referenceConf.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ exports.config = {
109109
maxInstances: 1,
110110

111111
// Additional spec files to be run on this capability only.
112-
specs: ['spec/chromeOnlySpec.js']
112+
specs: ['spec/chromeOnlySpec.js'],
113+
114+
// Spec files to be excluded on this capability only.
115+
exclude: ['spec/doNotRunInChromeSpec.js']
116+
113117
},
114118

115119
// If you would like to run more than one instance of WebDriver on the same

lib/taskScheduler.js

+9
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ var TaskScheduler = function(config) {
5555
capabilitySpecs = capabilitySpecs.concat(capabilitySpecificSpecs);
5656
}
5757

58+
if (capability.exclude) {
59+
var capabilitySpecExcludes = ConfigParser.resolveFilePatterns(
60+
capability.exclude, true, config.configDir);
61+
capabilitySpecs = ConfigParser.resolveFilePatterns(
62+
capabilitySpecs).filter(function(path) {
63+
return capabilitySpecExcludes.indexOf(path) < 0;
64+
});
65+
}
66+
5867
var specLists = [];
5968
// If we shard, we return an array of one element arrays, each containing
6069
// the spec file. If we don't shard, we return an one element array

spec/unit/taskScheduler_test.js

+22
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,26 @@ describe('the task scheduler', function() {
221221

222222
expect(scheduler.numTasksRemaining()).toEqual(0);
223223
});
224+
225+
it('should exclude capability-specific specs', function() {
226+
var toAdd = {
227+
specs: [
228+
'spec/unit/data/fakespecA.js',
229+
'spec/unit/data/fakespecB.js'
230+
],
231+
multiCapabilities: [{
232+
'browserName': 'chrome',
233+
exclude: 'spec/unit/data/fakespecB.js'
234+
}]
235+
};
236+
var config = new ConfigParser().addConfig(toAdd).getConfig();
237+
var scheduler = new TaskScheduler(config);
238+
239+
var task = scheduler.nextTask();
240+
expect(task.capability.browserName).toEqual('chrome');
241+
expect(task.specs.length).toEqual(1);
242+
243+
expect(scheduler.numTasksRemaining()).toEqual(0);
244+
});
245+
224246
});

0 commit comments

Comments
 (0)