Permalink
Browse files

feat(serenity): SerenityProtractorFramework takes care of executing c…

…ucumber and mocha tests.

BREAKING CHANGE: SerenityProtractorPlugin is now removed in favour of the much more flexible SerenityProtractorFramework.

You can use the SerenityProtractorFramework instead of the `mocha` or the `protractor-cucumber-framework` modules
as it provides capabilities equivalent to those modules, and also enables an easy integration with Serenity/JS
as well as synchronisation with the WebDriver ControlFlow so that the test reports will show accurate timing.

To enable the framework, add the following configuration to your `protractor.conf.js` file:

```javascript
exports.config = {
    framework: 'custom',

    frameworkPath: require.resolve('serenity-js'),
    serenity: {
        dialect: 'cucumber'     // or 'mocha'
    },

    specs: [ 'features/**/*.feature' ],

    cucumberOpts: {             // or 'mochaOpts'
    },
```

Both `cucumberOpts` and `mochaOpts` don't need to change as SerenityProtractorFramework can act as a drop-in replacement.

Please see the [`todomvc-protractor-cucumber`](examples/todomvc-protractor-cucumber) and [`todomvc-protractor-mocha`](examples/todomvc-protractor-mocha) example project for details.

BREAKING CHANGE: The `serenity` object should be used instead of the `Serenity` singleton to initialise
the stage and the actors.

Instead of:

```typescript
import { Serenity } from 'serenity-js';

const stage = Serenity.callToStageFor(cast);
```

use:

```typescript
import { serenity } from 'serenity-js';

const stage = serenity.callToStageFor(cast);
```

Tutorials and more documentation to follow shortly!
  • Loading branch information...
jan-molak committed Jan 27, 2017
1 parent dca8be0 commit 6cf0197a1a32152bc1dea14320746637269fd24a
Showing with 1,055 additions and 290 deletions.
  1. +0 −9 examples/todomvc-protractor-cucumber/features/cucumber.hooks.ts
  2. +2 −2 examples/todomvc-protractor-cucumber/features/step_definitions/todo_user.steps.ts
  3. +15 −19 examples/todomvc-protractor-cucumber/protractor.conf.js
  4. +8 −8 examples/todomvc-protractor-mocha/protractor.conf.js
  5. +2 −3 examples/todomvc-protractor-mocha/spec/find_things_to_do/filter_the_list.spec.ts
  6. +2 −2 examples/todomvc-protractor-mocha/spec/manage_the_todo_list/add_new_items.spec.ts
  7. +3 −4 examples/todomvc-protractor-mocha/spec/manage_the_todo_list/complete_items.spec.ts
  8. +3 −0 package.json
  9. +326 −0 spec/api/serenity-protractor/framework/protractor_reporter.spec.ts
  10. +1 −1 spec/api/serenity/stage/stage.spec.ts
  11. +3 −0 spec/integration/cucumber/features/step_definitions/steps.ts
  12. +0 −6 spec/integration/cucumber/features/support/hooks.ts
  13. +7 −6 spec/integration/cucumber/protractor.conf.js
  14. +9 −5 spec/integration/mocha/protractor.conf.js
  15. +5 −0 src/index.ts
  16. +18 −10 src/serenity-cucumber/cucumber_serenity_notifier.ts
  17. +89 −0 src/serenity-cucumber/cucumber_test_framework.ts
  18. +11 −2 src/serenity-cucumber/index.ts
  19. +2 −116 src/serenity-mocha/index.ts
  20. +61 −0 src/serenity-mocha/mocha_config.ts
  21. +65 −0 src/serenity-mocha/mocha_test_framework.ts
  22. +43 −39 src/serenity-mocha/model.ts
  23. +5 −0 src/serenity-protractor/framework/index.ts
  24. +42 −0 src/serenity-protractor/framework/protractor_report.ts
  25. +36 −0 src/serenity-protractor/framework/protractor_report_exporter.ts
  26. +62 −0 src/serenity-protractor/framework/protractor_reporter.ts
  27. +15 −0 src/serenity-protractor/framework/serenity_framework_config.ts
  28. +72 −0 src/serenity-protractor/framework/serenity_protractor_framework.ts
  29. +3 −0 src/serenity-protractor/framework/test_framework.ts
  30. +0 −3 src/serenity-protractor/plugin/index.ts
  31. +0 −36 src/serenity-protractor/plugin/serenity_protractor_plugin.ts
  32. +9 −1 src/serenity/domain/model.ts
  33. +5 −0 src/serenity/io/json.ts
  34. +2 −2 src/serenity/recording/step_annotation.ts
  35. +2 −0 src/serenity/reporting/index.ts
  36. +112 −0 src/serenity/reporting/rehearsal_report.ts
  37. +7 −0 src/serenity/reporting/report_exporter.ts
  38. +7 −15 src/serenity/serenity.ts
  39. +1 −1 src/serenity/stage/json_reporter.ts

This file was deleted.

Oops, something went wrong.
@@ -1,4 +1,4 @@
import { Serenity } from 'serenity-js';
import { serenity } from 'serenity-js';
import {
Actors,
@@ -18,7 +18,7 @@ export = function todoUserSteps() {
/**
* Initialises Serenity with a custom Cast of Actors, specific to your domain
*/
const stage = Serenity.callToStageFor(new Actors());
const stage = serenity.callToStageFor(new Actors());
this.Given(/^.*that (.*) has an empty todo list$/, (name: string) => {
@@ -1,4 +1,4 @@
require('ts-node/register');
// require('ts-node/register');
const crew = require('serenity-js/lib/stage_crew');
@@ -9,25 +9,25 @@ exports.config = {
allScriptsTimeout: 110000,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
specs: [ 'features/**/*.feature' ],
cucumberOpts: {
require: [ 'features/**/*.ts' ],
format: 'pretty',
compiler: 'ts:ts-node/register'
},
plugins: [{
path: 'node_modules/serenity-js/lib/serenity-protractor/plugin',
frameworkPath: require.resolve('serenity-js'),
serenity: {
dialect: 'cucumber',
crew: [
crew.jsonReporter(),
crew.consoleReporter(),
crew.Photographer.who(_ => _
.takesPhotosOf(_.Tasks_and_Interactions)
.takesPhotosWhen(_.Activity_Finishes)
.takesPhotosOf(_.Tasks_and_Interactions)
.takesPhotosWhen(_.Activity_Finishes)
)
]
}],
},
specs: [ 'features/**/*.feature' ],
cucumberOpts: {
require: [ 'features/**/*.ts' ],
format: 'pretty',
compiler: 'ts:ts-node/register'
},
capabilities: {
browserName: 'chrome',
@@ -41,9 +41,5 @@ exports.config = {
},
restartBrowserBetweenTests: true,
disableChecks: true,
onPrepare: function() {
browser.ignoreSynchronization = false;
}
disableChecks: true
};
@@ -9,20 +9,20 @@ exports.config = {
allScriptsTimeout: 110000,
framework: 'custom',
frameworkPath: 'node_modules/serenity-js/lib/serenity-mocha',
specs: [ 'spec/**/*.spec.ts' ],
plugins: [{
path: 'node_modules/serenity-js/lib/serenity-protractor/plugin',
frameworkPath: require.resolve('serenity-js'),
serenity: {
dialect: 'mocha',
crew: [
crew.jsonReporter(),
crew.consoleReporter(),
crew.Photographer.who(_ => _
.takesPhotosOf(_.Tasks_and_Interactions)
.takesPhotosWhen(_.Activity_Finishes)
.takesPhotosOf(_.Tasks_and_Interactions)
.takesPhotosWhen(_.Activity_Finishes)
)
]
}],
},
specs: [ 'spec/**/*.spec.ts' ],
capabilities: {
browserName: 'chrome',
@@ -1,12 +1,11 @@
import { Serenity } from 'serenity-js';
import { serenity } from 'serenity-js';
import { Actors, CompleteATodoItem, FilterItems, Start } from 'todomvc-model';
import { Ensure } from '../../src/tasks/ensure';
describe('Finding things to do', function() {
this.timeout(10000);
const stage = Serenity.callToStageFor(new Actors());
const stage = serenity.callToStageFor(new Actors());
describe('James can use filters so that the list', () => {
@@ -1,11 +1,11 @@
import { Serenity } from 'serenity-js';
import { serenity } from 'serenity-js';
import { Actors, AddATodoItem, Start } from 'todomvc-model';
import { Ensure } from '../../src/tasks/ensure';
describe('Managing a Todo List', function() {
this.timeout(10000);
const stage = Serenity.callToStageFor(new Actors());
const stage = serenity.callToStageFor(new Actors());
describe('James can add an item when his list', () => {
@@ -1,12 +1,11 @@
import { Serenity } from 'serenity-js';
import { Actors, CompleteATodoItem, ItemStatus, Start } from 'todomvc-model';
import { serenity } from 'serenity-js';
import { Actors, CompleteATodoItem, Start } from 'todomvc-model';
import { Ensure } from '../../src/tasks/ensure';
describe('Managing a Todo List', function() {
this.timeout(10000);
const stage = Serenity.callToStageFor(new Actors());
const stage = serenity.callToStageFor(new Actors());
describe('James', () => {
View
@@ -45,6 +45,7 @@
"@types/selenium-webdriver": "2.53.39",
"@types/stack-trace": "0.0.28",
"co": "4.6.0",
"glob": "7.1.1",
"graceful-fs": "4.1.11",
"is-generator": "1.0.3",
"lodash": "4.17.2",
@@ -60,6 +61,7 @@
"@types/chai-as-promised": "0.0.29",
"@types/cucumber": "0.0.35",
"@types/express": "4.0.34",
"@types/glob": "5.0.30",
"@types/mocha": "2.2.34",
"@types/mock-fs": "3.6.30",
"@types/nock": "8.2.0",
@@ -86,6 +88,7 @@
"istanbul": "0.4.5",
"istanbul-merge": "1.1.1",
"mocha": "3.2.0",
"mocha-testdata": "1.2.0",
"mock-fs": "4.0.0-beta.1",
"nock": "8.0.0",
"npm-failsafe": "0.2.1",
Oops, something went wrong.

0 comments on commit 6cf0197

Please sign in to comment.