Skip to content

Commit 3008c7b

Browse files
committed
refactored tests for integrated cucumber test runner
1 parent dfe1bc8 commit 3008c7b

29 files changed

+495
-142
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"eslint": "eslint index.js lib bin api examples cucumber-js test --quiet",
7979
"mocha-coverage": "nyc --reporter=html mocha test/src/ --recursive",
8080
"test": "mocha test/src/ --recursive",
81+
"test-cucumber": "mocha test/cucumber-integration-tests --parallel",
8182
"coverage": "npx nyc report --reporter=text-lcov > ./coverage/mocha_coverage.lcov"
8283
},
8384
"eslintConfig": {
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: Sample Feature
2+
@pass
3+
Scenario: Sample Scenario
4+
Given I navigate to localhost
5+
Then I check if webdriver is present
6+
7+
@expect
8+
Scenario: Sample Scenario with expect
9+
Given I navigate to localhost
10+
Then I check if webdriver is present and contains text
11+
12+
@fail
13+
Scenario: Sample test with failures
14+
Given I navigate to localhost
15+
Then I check if badElement is present
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const assert = require('assert');
2+
const {Given, Then, After} = require('@cucumber/cucumber');
3+
4+
Given('I navigate to localhost', function() {
5+
browser.globals.test_calls++;
6+
7+
return browser.navigateTo('http://localhost');
8+
});
9+
10+
Then('I check if webdriver is present', function() {
11+
browser.globals.test_calls++;
12+
13+
return browser.assert.elementPresent('#webdriver');
14+
});
15+
16+
Then('I check if webdriver is present and contains text', async function() {
17+
browser.globals.test_calls++;
18+
19+
await browser.expect.element('#webdriver').text.to.contain('xx')
20+
});
21+
22+
Then('I check if badElement is present', function() {
23+
browser.globals.test_calls++;
24+
25+
return browser.assert.elementPresent('#badElement');
26+
});
27+
28+
After(function() {
29+
assert.strictEqual(browser.globals.test_calls, 2);
30+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const {Given, Then} = require('@cucumber/cucumber');
2+
3+
Given('I navigate to localhost', function() {
4+
browser.globals.test_calls++;
5+
return browser.url('http://localhost');
6+
});
7+
8+
Then('I check if badElement is present', function() {
9+
browser.globals.test_calls++;
10+
return browser.assert.elementPresent('#badElement');
11+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: Sample Feature
2+
@pass
3+
Scenario: Sample Scenario
4+
Given I navigate to localhost
5+
Then I check if webdriver is present
6+
7+
@expect
8+
Scenario: Sample Scenario with expect
9+
Given I navigate to localhost
10+
Then I check if webdriver is present and contains text
11+
12+
@fail
13+
Scenario: Sample test with failures
14+
Given I navigate to localhost
15+
Then I check if badElement is present
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const assert = require('assert');
2+
const {Given, Then, After} = require('@cucumber/cucumber');
3+
4+
Given('I navigate to localhost', function() {
5+
browser.globals.test_calls++;
6+
7+
return browser.navigateTo('http://localhost');
8+
});
9+
10+
Then('I check if webdriver is present', function() {
11+
browser.globals.test_calls++;
12+
13+
return browser.assert.elementPresent('#webdriver');
14+
});
15+
16+
Then('I check if webdriver is present and contains text', async function() {
17+
browser.globals.test_calls++;
18+
19+
await browser.expect.element('#webdriver').text.to.contain('xx')
20+
});
21+
22+
Then('I check if badElement is present', function() {
23+
browser.globals.test_calls++;
24+
25+
return browser.assert.elementPresent('#badElement');
26+
});
27+
28+
After(function() {
29+
assert.strictEqual(browser.globals.test_calls, 2);
30+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const {Given, Then} = require('@cucumber/cucumber');
2+
3+
Given('I navigate to localhost', function() {
4+
browser.globals.test_calls++;
5+
return browser.url('http://localhost');
6+
});
7+
8+
Then('I check if badElement is present', function() {
9+
browser.globals.test_calls++;
10+
return browser.assert.elementPresent('#badElement');
11+
});

0 commit comments

Comments
 (0)