Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protractor): ProtractorFrameworkAdapter for Cucumber
And other small fixes here and there
- Loading branch information
Showing
159 changed files
with
1,896 additions
and
439 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,7 @@ | ||
# Node | ||
node_modules | ||
*.log | ||
|
||
# Build artifacts | ||
.nyc_output | ||
lib |
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,6 @@ | ||
Feature: Interactions | ||
|
||
Scenario: Actor interacts with a webiste | ||
|
||
When Umbra navigates to the test website | ||
Then she should see the title of "Test Website" |
25 changes: 25 additions & 0 deletions
25
examples/protractor-cucumber/features/step_definitions/ui.steps.ts
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,25 @@ | ||
import { Ensure, equals } from '@serenity-js/assertions'; | ||
import { WithStage } from '@serenity-js/cucumber'; | ||
import { LocalServer, StartLocalServer, StopLocalServer } from '@serenity-js/local-server'; | ||
import { Navigate, UseAngular, Website } from '@serenity-js/protractor'; | ||
import { After, Then, When } from 'cucumber'; | ||
|
||
When(/^(.*) navigates to the test website$/, function(this: WithStage, actorName: string) { | ||
return this.stage.actor(actorName).attemptsTo( | ||
StartLocalServer.onRandomPort(), | ||
UseAngular.disableSynchronisation(), | ||
Navigate.to(LocalServer.url()), | ||
); | ||
}); | ||
|
||
Then(/(?:he|she|they) should see the title of "(.*)"/, function(this: WithStage, expectedTitle: string) { | ||
return this.stage.theActorInTheSpotlight().attemptsTo( | ||
Ensure.that(Website.title(), equals(expectedTitle)), | ||
); | ||
}); | ||
|
||
After(function () { | ||
return this.stage.theActorCalled('Umbra').attemptsTo( | ||
StopLocalServer.ifRunning(), | ||
); | ||
}); |
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,15 @@ | ||
import express = require('express'); | ||
|
||
export const app = express() | ||
.get('/', (req: express.Request, res: express.Response) => { | ||
|
||
res.send(`<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Test Website</title> | ||
</head> | ||
<body /> | ||
</html> | ||
`); | ||
}); |
21 changes: 21 additions & 0 deletions
21
examples/protractor-cucumber/features/support/configure_serenity.ts
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,21 @@ | ||
import { serenity } from '@serenity-js/core'; | ||
import { FileSystem, Path } from '@serenity-js/core/lib/io'; | ||
import { ArtifactArchiver, ConsoleReporter, DebugReporter, SerenityBDDReporter } from '@serenity-js/core/lib/stage'; | ||
import { WithStage } from '@serenity-js/cucumber'; | ||
|
||
import { setDefaultTimeout, setWorldConstructor } from 'cucumber'; | ||
import { Actors } from './screenplay'; | ||
|
||
// todo: move to config and make the artifact archiver config more intuitive | ||
serenity.setTheStage( | ||
new ArtifactArchiver(new FileSystem(new Path('./target/site/serenity'))), | ||
new SerenityBDDReporter(), | ||
// new DebugReporter(), | ||
new ConsoleReporter(), | ||
); | ||
|
||
setDefaultTimeout(1000); | ||
|
||
setWorldConstructor(function(this: WithStage, { parameters }) { | ||
this.stage = serenity.callToStageFor(new Actors()); | ||
}); |
14 changes: 14 additions & 0 deletions
14
examples/protractor-cucumber/features/support/screenplay/Actors.ts
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,14 @@ | ||
import { Actor, DressingRoom } from '@serenity-js/core'; | ||
import { ManageALocalServer } from '@serenity-js/local-server'; | ||
import { BrowseTheWeb } from '@serenity-js/protractor'; | ||
import { protractor } from 'protractor'; | ||
import { app } from '../app'; | ||
|
||
export class Actors implements DressingRoom { | ||
prepare(actor: Actor): Actor { | ||
return actor.whoCan( | ||
BrowseTheWeb.using(protractor.browser), | ||
ManageALocalServer.runningAHttpListener(app), | ||
); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
examples/protractor-cucumber/features/support/screenplay/index.ts
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 @@ | ||
export * from './Actors'; |
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,54 @@ | ||
{ | ||
"name": "@serenity-js-examples/protractor-cucumber", | ||
"version": "2.0.1-alpha.47", | ||
"description": "Example implementation of a test suite using Protractor and Cucumber to exercise a Web interface", | ||
"author": { | ||
"name": "Jan Molak", | ||
"email": "jan.molak@smartcodeltd.co.uk", | ||
"url": "https://janmolak.com" | ||
}, | ||
"homepage": "http://serenity-js.org", | ||
"license": "Apache-2.0", | ||
"private": true, | ||
"config": { | ||
"access": "private" | ||
}, | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"scripts": { | ||
"clean": "rimraf target", | ||
"lint": "tslint --project tsconfig-lint.json --config ../../tslint.json --format stylish", | ||
"test:update-serenity": "serenity update --artifact net.serenity-bdd:serenity-cli:jar:all:2.1.8 --repository https://jcenter.bintray.com/ --ignoreSSL", | ||
"test:acceptance": "protractor ./protractor.conf.js", | ||
"test:report": "serenity run --artifact net.serenity-bdd:serenity-cli:jar:all:2.1.8", | ||
"test": "failsafe clean test:update-serenity test:acceptance test:report", | ||
"verify": "npm test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jan-molak/serenity-js.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/jan-molak/serenity-js/issues" | ||
}, | ||
"engines": { | ||
"node": ">= 6.9.x", | ||
"npm": ">= 3" | ||
}, | ||
"devDependencies": { | ||
"@serenity-js/assertions": "2.0.1-alpha.47", | ||
"@serenity-js/core": "2.0.1-alpha.47", | ||
"@serenity-js/cucumber": "2.0.1-alpha.47", | ||
"@serenity-js/local-server": "2.0.1-alpha.47", | ||
"@serenity-js/protractor": "2.0.1-alpha.47", | ||
"@types/cucumber": "^4.0.5", | ||
"@types/express": "^4.16.1", | ||
"chromedriver": "^2.46.0", | ||
"cucumber": "^5.1.0", | ||
"express": "^4.16.4", | ||
"npm-failsafe": "0.4.1", | ||
"protractor": "^5.4.2", | ||
"serenity-cli": "^0.11.3", | ||
"ts-node": "^8.1.0" | ||
} | ||
} |
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,36 @@ | ||
exports.config = { | ||
chromeDriver: require('chromedriver/lib/chromedriver').path, | ||
SELENIUM_PROMISE_MANAGER: false, | ||
|
||
directConnect: true, | ||
|
||
allScriptsTimeout: 11000, | ||
|
||
specs: [ 'features/*.feature', ], | ||
|
||
framework: 'custom', | ||
frameworkPath: require.resolve('@serenity-js/protractor/adapter'), | ||
|
||
cucumberOpts: { | ||
require: [ | ||
'features/step_definitions/**/*.ts', | ||
'features/support/configure_serenity.ts', | ||
], | ||
'require-module': ['ts-node/register'], | ||
tags: [], | ||
}, | ||
|
||
capabilities: { | ||
browserName: 'chrome', | ||
|
||
chromeOptions: { | ||
args: [ | ||
'--disable-infobars', | ||
'--no-sandbox', | ||
'--disable-gpu', | ||
'--window-size=1024x768', | ||
'--headless', | ||
], | ||
}, | ||
}, | ||
}; |
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,10 @@ | ||
{ | ||
"extends": "./tsconfig", | ||
"include": [ | ||
"src/**/*.ts", | ||
"spec/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
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,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": [ "es5", "es6" ], | ||
"module": "commonjs", | ||
"sourceMap": true, | ||
"declaration": true | ||
}, | ||
|
||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
6 changes: 3 additions & 3 deletions
6
integration/cucumber-1-runner/src/step_definitions/ambiguous.steps.ts
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
export = function() { | ||
this.Given(/^.*step (?:.*) passes$/, function() { | ||
export = function () { | ||
this.Given(/^.*step (?:.*) passes$/, function () { | ||
return void 0; | ||
}); | ||
|
||
this.Given(/^.*step (?:.*) passes$/, function() { | ||
this.Given(/^.*step (?:.*) passes$/, function () { | ||
return void 0; | ||
}); | ||
}; |
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
16 changes: 8 additions & 8 deletions
16
integration/cucumber-1-runner/src/step_definitions/promise.steps.ts
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
37 changes: 37 additions & 0 deletions
37
integration/cucumber-1-runner/src/step_definitions/screenplay.steps.ts
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,37 @@ | ||
import { Interaction } from '@serenity-js/core'; | ||
import { WithStage } from '@serenity-js/cucumber'; | ||
|
||
const | ||
MakeAnArrow = () => Interaction.where(`#actor makes an arrow`, actor => void 0), | ||
Nock = () => Interaction.where(`#actor fits an arrow to the bowstring`, actor => void 0), | ||
Draw = () => Interaction.where(`#actor draws the bow`, actor => void 0), | ||
Loose = () => Interaction.where(`#actor releases the bowstring`, actor => void 0), | ||
RetrieveArrow = () => Interaction.where(`#actor retrieves the arrow from the target`, actor => void 0); | ||
|
||
export = function () { | ||
this.Before(function (this: WithStage) { | ||
return this.stage.theActorCalled('Lara').attemptsTo( | ||
MakeAnArrow(), | ||
); | ||
}); | ||
|
||
this.When(/^(.*) shoots an arrow$/, function (this: WithStage, actorName: string) { | ||
return this.stage.theActorCalled(actorName).attemptsTo( | ||
Nock(), | ||
Draw(), | ||
Loose(), | ||
); | ||
}); | ||
|
||
this.Then(/^she should hit a target$/, function (this: WithStage) { | ||
return this.stage.theActorInTheSpotlight().attemptsTo( | ||
// some assertion | ||
); | ||
}); | ||
|
||
this.After(function (this: WithStage) { | ||
return this.stage.theActorCalled('Lara').attemptsTo( | ||
RetrieveArrow(), | ||
); | ||
}); | ||
}; |
Oops, something went wrong.