-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more supporting CucumberJS cli options (#2978)
- Loading branch information
Showing
3 changed files
with
122 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
const mockery = require('mockery'); | ||
const common = require('../../../common.js'); | ||
const CucumberRunner = common.require('runner/test-runners/cucumber.js'); | ||
|
||
|
||
|
||
|
||
describe('Cucumber cli arguements', function(){ | ||
let cliArgs; | ||
|
||
this.beforeAll(function(){ | ||
mockery.enable(); | ||
mockery.registerMock('@cucumber/cucumber/lib/cli/index', | ||
{ | ||
default: class CucumberCli { | ||
constructor({ | ||
argv, cwd, stdout | ||
}){ | ||
cliArgs =argv; | ||
} | ||
} | ||
|
||
}); | ||
}); | ||
|
||
this.afterAll(function(){ | ||
mockery.deregisterAll(); | ||
mockery.disable(); | ||
}); | ||
|
||
it('Cucumber cli args --require-modules', function(){ | ||
const runner = new CucumberRunner({test_runner: { | ||
type: 'cucumber', | ||
options: {} | ||
}}, {'require-module': ['coffeescript/register', 'ts-node/register']}); | ||
runner.createTestSuite({modules: [path.join(__dirname, '../../../cucumbertests/testSample.js')], modulePath: [path.join(__dirname, '../../../cucumbertests/testSample.js')]}); | ||
assert.ok(cliArgs.includes('--require-module')); | ||
let index = cliArgs.indexOf('--require-module')+1; | ||
assert.strictEqual(cliArgs[index], 'coffeescript/register'); | ||
index = cliArgs.indexOf('--require-module', index)+1; | ||
assert.strictEqual(cliArgs[index], 'ts-node/register'); | ||
}); | ||
|
||
it('Cucumber cli args', function(){ | ||
const runner = new CucumberRunner({test_runner: { | ||
type: 'cucumber', | ||
options: {} | ||
}}, {'no-strict': true, retries: 2, profile: 'local', 'fail-fast': true, parallel: 3, name: 'sample', 'retry-tag-filter': '@nightwatch'}, {}); | ||
runner.createTestSuite({modules: [path.join(__dirname, '../../../cucumbertests/testSample.js')], modulePath: [path.join(__dirname, '../../../cucumbertests/testSample.js')]}); | ||
assert.ok(cliArgs.includes('--name')); | ||
assert.strictEqual(cliArgs[cliArgs.indexOf('--name')+1], 'sample'); | ||
assert.ok(cliArgs.includes('--fail-fast')); | ||
assert.ok(cliArgs.includes('--retry')); | ||
assert.strictEqual(cliArgs[cliArgs.indexOf('--retry')+1], 2); | ||
assert.ok(cliArgs.includes('--retry-tag-filter')); | ||
assert.strictEqual(cliArgs[cliArgs.indexOf('--retry-tag-filter')+1], '@nightwatch'); | ||
assert.ok(cliArgs.includes('--profile')); | ||
assert.strictEqual(cliArgs[cliArgs.indexOf('--profile')+1], 'local'); | ||
assert.ok(cliArgs.includes('--no-strict')); | ||
assert.ok(cliArgs.includes('--parallel')); | ||
assert.strictEqual(cliArgs[cliArgs.indexOf('--parallel')+1], 3); | ||
}); | ||
|
||
it('Cucumber cli arg --dry-run', function(){ | ||
const runner = new CucumberRunner({test_runner: { | ||
type: 'cucumber', | ||
options: {} | ||
}}, {'dry-run': true}, {}); | ||
runner.createTestSuite({modules: [path.join(__dirname, '../../../cucumbertests/testSample.js')], modulePath: [path.join(__dirname, '../../../cucumbertests/testSample.js')]}); | ||
assert.ok(cliArgs.includes('--dry-run')); | ||
}); | ||
|
||
}); |