Skip to content

Commit

Permalink
convert to cucumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Warrens, Matthew (CORP) authored and Warrens, Matthew (CORP) committed Dec 1, 2017
1 parent f56323b commit 0e1a14c
Show file tree
Hide file tree
Showing 23 changed files with 165 additions and 90 deletions.
4 changes: 2 additions & 2 deletions .angular-cli.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "./node_modules/@nrwl/schematics/src/schema.json",
"project": {
"name": "nrwl-protractor",
"npmScope": "nrwl-protractor",
"name": "nrwl-cucumber",
"npmScope": "nrwl-cucumber",
"latestMigration": "0.2.2"
},
"apps": [
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ testem.log
/typings

# e2e
/e2e/*.js
/e2e/*.map
/e2e/output

# System Files
.DS_Store
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,20 @@
This is an example of a nrwl workspace using Cucumber & Protractor. By default nrwl workspaces use Jasmin & Protractor.

For more details see the [wiki](https://github.com/mrwarrens/nrwl-cucumber/wiki)


#### Commands

Serve myapp1, then run e2e tests against that server

`ng e2e --app=myapp1`

Run against a remove server

`ng e2e --app=myapp1 --serve=false --base-url=http://my.remote.server.com/app-context/`

Skip updating webdriver

`ng e2e --app=myapp1 --webdriver-update=false`

*Note this implementation makes `app` a required parameter.*
14 changes: 0 additions & 14 deletions apps/myapp1/e2e/app.e2e-spec.ts

This file was deleted.

11 changes: 0 additions & 11 deletions apps/myapp1/e2e/app.po.ts

This file was deleted.

6 changes: 6 additions & 0 deletions apps/myapp1/e2e/features/app.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: myapp1 App
myapp1 Application does things

Scenario: Welcome message
Given I am on the landing page
Then I should see a welcome message
11 changes: 11 additions & 0 deletions apps/myapp1/e2e/steps/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { browser, by } from 'protractor';

export class AppPage {
public navigateTo() {
return browser.get('#');
}

public getText() {
return browser.findElement(by.css('body')).getText();
}
}
18 changes: 18 additions & 0 deletions apps/myapp1/e2e/steps/app.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect } from 'chai';
import { defineSupportCode } from 'cucumber';

import { AppPage } from './app.po';

defineSupportCode(({ Given, Then, Before }) => {
let app: AppPage;

Before(() => {
app = new AppPage();
});

Given('I am on the landing page', () => app.navigateTo());

Then('I should see a welcome message', () => {
return expect(app.getText()).to.eventually.contains('Welcome to an Angular CLI app built with Nrwl Nx! myapp1');
});
});
2 changes: 1 addition & 1 deletion apps/myapp1/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div style="text-align:center">
<h1>
Welcome to an Angular CLI app built with Nrwl Nx!
Welcome to an Angular CLI app built with Nrwl Nx! myapp1
</h1>
<img width="300" src="assets/nx-logo.png">
</div>
Expand Down
14 changes: 0 additions & 14 deletions apps/myapp2/e2e/app.e2e-spec.ts

This file was deleted.

11 changes: 0 additions & 11 deletions apps/myapp2/e2e/app.po.ts

This file was deleted.

6 changes: 6 additions & 0 deletions apps/myapp2/e2e/features/app.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: myapp2 App
myapp2 Application does things

Scenario: Welcome message
Given I am on the landing page
Then I should see a welcome message
11 changes: 11 additions & 0 deletions apps/myapp2/e2e/steps/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { browser, by } from 'protractor';

export class AppPage {
public navigateTo() {
return browser.get('#');
}

public getText() {
return browser.findElement(by.css('body')).getText();
}
}
18 changes: 18 additions & 0 deletions apps/myapp2/e2e/steps/app.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect } from 'chai';
import { defineSupportCode } from 'cucumber';

import { AppPage } from './app.po';

defineSupportCode(({ Given, Then, Before }) => {
let app: AppPage;

Before(() => {
app = new AppPage();
});

Given('I am on the landing page', () => app.navigateTo());

Then('I should see a welcome message', () => {
return expect(app.getText()).to.eventually.contains('Welcome to an Angular CLI app built with Nrwl Nx! myapp2');
});
});
2 changes: 1 addition & 1 deletion apps/myapp2/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div style="text-align:center">
<h1>
Welcome to an Angular CLI app built with Nrwl Nx!
Welcome to an Angular CLI app built with Nrwl Nx! myapp2
</h1>
<img width="300" src="assets/nx-logo.png">
</div>
Expand Down
20 changes: 20 additions & 0 deletions e2e/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");

module.exports = {
setup: function() {
try {

chai.use(chaiAsPromised);

} catch (e) {
return browser.quit().then(function () {
return process.exit(e);
});
}
},

name: 'core'
};
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "nrwl-protractor",
"name": "nrwl-cucumber",
"version": "0.0.0",
"license": "MIT",
"scripts": {
Expand Down Expand Up @@ -36,10 +36,14 @@
"@angular/compiler-cli": "5.0.0",
"@nrwl/schematics": "0.2.2",
"@angular/language-service": "5.0.0",
"@types/cucumber": "^2.0.4",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"chai": "^4.1.2",
"chai-as-promised": "7.1.1",
"codelyzer": "~3.1.1",
"cucumber": "^3.1.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
Expand All @@ -49,9 +53,11 @@
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"protractor-cucumber-framework": "^4.1.1",
"ts-node": "~3.2.0",
"tslint": "~5.3.2",
"typescript": "2.5.3",
"prettier": "1.7.4"
"prettier": "1.7.4",
"yargs": "10.0.3"
}
}
51 changes: 39 additions & 12 deletions protractor.conf.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,55 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
require('ts-node/register');
const argv = require('yargs').argv;
const baseUrl = argv['base-url'] || 'http://localhost:4200/';

const { SpecReporter } = require('jasmine-spec-reporter');
if(!argv.app) {
throw new Error('Missing required parameter app: (ng e2e --app=appname)');
}

exports.config = {
allScriptsTimeout: 11000,
specs: [
'./apps/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox']
}
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
baseUrl: baseUrl,

// Specs here are the cucumber feature files
specs: ['./apps/' + argv.app + '/**/e2e/features/*.feature'],

// Use a custom framework adapter and set its relative path
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),

plugins: [{
path: 'e2e/core.js'
}],

// cucumber command line options
cucumberOpts: {
// require step definition files before executing features
require: ['./apps/' + argv.app + '/**/e2e/steps/**/*.steps.ts'],
// <string[]> (expression) only execute the features or scenarios with tags matching the expression
// tags: [],
// <boolean> fail if there are any undefined or pending steps
strict: true,
// <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
format: ['json:./e2e/output/' + argv.app + '-results.json'],
// <boolean> invoke formatters without executing steps
dryRun: false,
// <string[]> ("extension:module") require files with the given EXTENSION after requiring MODULE (repeatable)
compiler: []
},

// Enable TypeScript for the tests
onPrepare() {
require('ts-node').register({
project: './tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
2 changes: 1 addition & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"module": "es2015",
"baseUrl": ".",
"paths": {
"@nrwl-protractor/*": [
"@nrwl-cucumber/*": [
"libs/*"
]
}
Expand Down
18 changes: 2 additions & 16 deletions tsconfig.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,7 @@
"outDir": "./out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
],
"baseUrl": ".",
"paths": {
"@nrwl-protractor/*": [
"libs/*"
]
}
"types": ["cucumber", "node", "selenium-webdriver"]
},
"exclude": [
"**/*.spec.ts",
"node_modules",
"tmp"
]
"exclude": ["**/*.spec.ts", "node_modules", "tmp"]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"baseUrl": ".",
"paths": {
"@nrwl-protractor/*": [
"@nrwl-cucumber/*": [
"libs/*"
]
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"baseUrl": ".",
"paths": {
"@nrwl-protractor/*": [
"@nrwl-cucumber/*": [
"libs/*"
]
}
Expand Down
2 changes: 1 addition & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"nx-enforce-module-boundaries": [
true,
{
"npmScope": "nrwl-protractor",
"npmScope": "nrwl-cucumber",
"lazyLoad": []
}
]
Expand Down

0 comments on commit 0e1a14c

Please sign in to comment.