-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 80e0cb9
Showing
7 changed files
with
1,767 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
HOST=https://google.ch |
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,2 @@ | ||
.env | ||
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,63 @@ | ||
|
||
# Installation | ||
|
||
You need to set up your development environment before you can do anything. | ||
|
||
Install [Node.js and NPM](https://nodejs.org/en/download/) | ||
|
||
- on OSX use [homebrew](http://brew.sh) `brew install node` | ||
- on Windows use [chocolatey](https://chocolatey.org/) `choco install nodejs` | ||
|
||
Install yarn globally | ||
|
||
```bash | ||
npm install yarn -g | ||
``` | ||
|
||
Then install the dependencies with | ||
```bash | ||
yarn install | ||
``` | ||
|
||
Then copy the `.env.example` to `.env` and replace the setting in the file with your settings | ||
```bash | ||
cp .env.example .env | ||
``` | ||
|
||
# Usage | ||
|
||
This repository uses the [testcafe](https://devexpress.github.io/testcafe/) library to perform e2e tests. | ||
|
||
## Running the tests | ||
|
||
You can run all tests by | ||
```bash | ||
npm test | ||
``` | ||
|
||
or just run a single file by | ||
```bash | ||
npm run test:single <path-to-file> | ||
|
||
npm run test:single tests/test-case.spec.ts | ||
``` | ||
|
||
## Write tests | ||
|
||
All test are located in `tests/`. See example `estate.ts`. | ||
There is also a helper utility `helper.ts` which can be imported and provides some help. | ||
The `helper.ts` can also be extended. | ||
|
||
## Documentation | ||
|
||
[Here you can find help about seleting elements (e.g. get text)](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors.html) | ||
|
||
[Here you can find help about actions elements (e.g. clicks)](https://devexpress.github.io/testcafe/documentation/test-api/actions/) | ||
|
||
[Here you can find help about Aurelia specific stuff](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/framework-specific-selectors.html#aurelia) | ||
|
||
## CI | ||
|
||
To run the all test headless use `npm run ci`. | ||
|
||
Additional information about CI integrations can be found [here](https://devexpress.github.io/testcafe/documentation/recipes/integrating-testcafe-with-ci-systems/). |
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,35 @@ | ||
{ | ||
"name": "test-cafe-e2e", | ||
"version": "1.0.0", | ||
"description": "E2E testing for almost any frontend app", | ||
"scripts": { | ||
"test": "testcafe chrome tests/**/*.spec.ts", | ||
"test:single": "testcafe chrome", | ||
"ci": "testcafe chrome:headless tests/**/*.spec.ts" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/w3tecch/test-cafe-e2e/issues" | ||
}, | ||
"homepage": "https://github.com/w3tecch/test-cafe-e2e#readme", | ||
"license": "MIT", | ||
"keywords": [ | ||
"e2e", | ||
"testcafe", | ||
"w3tec", | ||
"boilerplate" | ||
], | ||
"contributors": [ | ||
{ | ||
"name": "Gery Hirschfeld <[email protected]> (https://github.com/hirsch88)" | ||
}, | ||
{ | ||
"name": "David Weber <[email protected]> (https://github.com/dweber019)" | ||
} | ||
], | ||
"devDependencies": { | ||
"@types/dotenv": "^4.0.2", | ||
"dotenv": "^4.0.0", | ||
"testcafe": "^0.18.5", | ||
"testcafe-aurelia-selectors": "^0.1.3" | ||
} | ||
} |
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,39 @@ | ||
import { config } from 'dotenv'; | ||
import { ClientFunction, Selector } from 'testcafe'; | ||
|
||
import { getBrowserTitle, handleAuthentication } from './helper'; | ||
|
||
config(); | ||
|
||
fixture`Google` | ||
.page(process.env.HOST); | ||
// .beforeEach(async t => { | ||
// await handleAuthentication(t); | ||
// }); | ||
|
||
test('Should display google start page', async t => { | ||
|
||
const title = await getBrowserTitle(); | ||
await t | ||
.expect(title).eql('Google'); | ||
}); | ||
|
||
|
||
|
||
test('Should show results for e2e testing', async t => { | ||
|
||
const searchTerm = 'e2e testing'; | ||
const searchInput = Selector('#lst-ib'); | ||
|
||
await t | ||
.typeText(searchInput, searchTerm); | ||
|
||
const searchButton = Selector('input[name=btnK]'); | ||
|
||
await t | ||
.click(searchButton); | ||
|
||
const title = await getBrowserTitle(); | ||
await t | ||
.expect(title).contains(searchTerm); | ||
}); |
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,22 @@ | ||
import { ClientFunction, Role } from 'testcafe'; | ||
|
||
/** | ||
* Helper functions | ||
*/ | ||
export const getBrowserTitle = ClientFunction(() => document.title); | ||
|
||
/** | ||
* Authentication handling example | ||
*/ | ||
const regularUser = Role(`${process.env.HOST}/#/login`, async t => { | ||
await t | ||
.click('.login__button button') | ||
.typeText('.ui-inputfield', process.env.EMAIL) | ||
.click('.submitButton') | ||
.typeText('.ui-inputfield', process.env.PASSWORD) | ||
.click('.submitButton'); | ||
}, { preserveUrl: true }); | ||
|
||
export const handleAuthentication = async (t: TestController) => { | ||
await t.useRole(regularUser); | ||
} |
Oops, something went wrong.