Skip to content

Commit bb9c194

Browse files
committed
Initial commit
0 parents  commit bb9c194

File tree

9 files changed

+120
-0
lines changed

9 files changed

+120
-0
lines changed

cypress.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"testFiles": "**/*.feature"
3+
}

cypress.scaffold.framework.png

65.5 KB
Loading

cypress/fixtures/example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Feature: Validate the login page
2+
3+
Background:
4+
Given I navigate to the Entry Central login page
5+
6+
Scenario: When I navigate to the login page
7+
Then I should see "EntryCentral.com" displayed as the page title
8+
9+
Scenario: When I log in with an incorrect email/password combination
10+
When I login with an "invalid" credential combination
11+
Then I should see the "Invalid credentials" login error message
12+
13+
Scenario: When I log in with a valid registered email/password combination
14+
When I login with a "valid" credential combination
15+
Then I should see "Account - EntryCentral.com" displayed as the page title
16+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Created by stuart1 on 31/10/2019.
3+
*/
4+
import { Given, When, Then} from "cypress-cucumber-preprocessor/steps";
5+
6+
Given('I navigate to the Entry Central login page', () => {
7+
cy.navigate('/login')
8+
});
9+
10+
When('I login with a/an {string} credential combination', (credType) => {
11+
cy.fillLoginCredentials(credType)
12+
});
13+
14+
Then('I should see {string} displayed as the page title', (pageTitle) => {
15+
cy.title().should('eq', pageTitle)
16+
});
17+
18+
Then('I should see the {string} login error message', (message) => {
19+
cy.get('.alert').should('contain.text', message)
20+
});

cypress/plugins/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ***********************************************************
2+
// This example plugins/index.js can be used to load plugins
3+
//
4+
// You can change the location of this file or turn off loading
5+
// the plugins file with the 'pluginsFile' configuration option.
6+
//
7+
// You can read more here:
8+
// https://on.cypress.io/plugins-guide
9+
// ***********************************************************
10+
11+
// This function is called when a project is opened or re-opened (e.g. due to
12+
// the project's config changing)
13+
14+
const cucumber = require('cypress-cucumber-preprocessor').default
15+
16+
module.exports = (on, config) => {
17+
on('file:preprocessor', cucumber())
18+
};

cypress/support/commands.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Cypress.Commands.add("navigate", (path) => {
2+
cy
3+
.visit('https://www.entrycentral.com' + path)
4+
.get('#ccc-close')
5+
.click();
6+
});
7+
8+
Cypress.Commands.add("fillLoginCredentials", (credType) => {
9+
cy
10+
.get('#username').type(Cypress.env(credType + 'User'))
11+
.get('#password').type(Cypress.env(credType + 'Password'))
12+
.get('#_submit').click()
13+
});

cypress/support/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "cypress-framework-custom-commands",
3+
"version": "1.0.0",
4+
"description": "Cypress without Page Objects",
5+
"main": "index.js",
6+
"cypress-cucumber-preprocessor": {
7+
"nonGlobalStepDefinitions": true
8+
},
9+
"scripts": {
10+
"test": "echo \"Error: no test specified\" && exit 1",
11+
"cyrun": "node_modules/.bin/cypress run --browser chrome"
12+
},
13+
"keywords": [
14+
"Cypress",
15+
"Cucumber",
16+
"BDD"
17+
],
18+
"author": "Stuart Robertson",
19+
"license": "ISC",
20+
"devDependencies": {
21+
"cosmiconfig": "^6.0.0",
22+
"cypress": "^3.6.0",
23+
"cypress-cucumber-preprocessor": "^1.16.2"
24+
}
25+
}

0 commit comments

Comments
 (0)