Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jvitor83/angularcli-cucumber
https://github.com/jvitor83/angularcli-cucumber
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jvitor83/angularcli-cucumber
- Owner: jvitor83
- License: mit
- Created: 2018-08-17T23:40:41.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-20T15:58:42.000Z (about 6 years ago)
- Last Synced: 2024-10-04T03:40:59.210Z (about 1 month ago)
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
1) Create Angular App
```sh
ng new AngularCucumber
```1) Install the global tools:
```sh
npm install -g protractor cucumber
```
1) Install the required libraries:
```sh
npm install --save-dev cucumber @types/cucumber protractor-cucumber-framework chai @types/chai chai-as-promised @types/chai cucumber-junit globule mkdirp
```1) Replace the content of `e2e/protractor.conf.js` with:
```js
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const cucumberXmlReport = require('cucumber-junit');exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/features/**/*.feature'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
cucumberOpts: {
compiler: ['ts:ts-node/register'],
require: [ './src/features/**/*.e2e-spec.ts' ],
tags: ["~@ignore"],
strict: true,
format: 'json:./TestResults/integrationtest/testresults/cucumber_report.json',
'dry-run': false
},
suites: getSuites(),
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
const dirName = process.cwd() + '/TestResults/integrationtest/testresults';
if (!require('fs').existsSync(dirName)) {
require('mkdirp').sync(dirName);
}
},
onComplete: () => {
const fs = require('fs');
const fileContent = fs.readFileSync('./TestResults/integrationtest/testresults/cucumber_report.json', 'utf8');
const junitReportContent = cucumberXmlReport(fileContent, {strict: true});
fs.writeFileSync('./TestResults/integrationtest/testresults/cucumber_report.xml', junitReportContent);
}
};function getSuites() {
const fileSufix = ".feature";
const globulePathsArray = require(`globule`).find([ `${process.cwd()}/e2e/src/features/**/*${fileSufix}` ]);
const suites = { };
globulePathsArray.forEach(pathFile => {
const filename = require("path").basename(pathFile);
const filenameWithoutSufix = filename.replace(fileSufix, '');
suites[filenameWithoutSufix] = pathFile;
});
return suites;
}
```1) Copy the files of `e2e/src` to `e2e/src/pages`
1) Delete the file `e2e/src/pages/app.e2e-spec.ts`
1) Create the directory `e2e/src/features`
1) Create the file `e2e/src/features/example.feature` with the content:
```gherkin
Feature: HomeScenario: A first scenario
Given I am on the software
When i go to the app page
Then should display the welcome message "Welcome to AngularCucumber!"
```
1) Create the file `e2e/src/features/example/example.e2e-spec.ts` with the content:
```typescript
import { Given, When, Then } from 'cucumber';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import { AppPage } from '../../pages/app.po';
chai.use(chaiAsPromised);
const expect = chai.expect;let page: AppPage;
Given(/^I am on the software$/, () => {
page = new AppPage();
});When(/^i go to the app page$/, () => {
return page.navigateTo();
});Then(/^should display the welcome message "(.*?)"$/, async (expectedTitle: string) => {
return page.getParagraphText().then(paragraphText => expect(paragraphText).to.be.equal(expectedTitle));
});
```
1) Execute `ng e2e --suite=example`