-
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.
SUIT-9356 Move mocha set-up demo from JS API repo to demo repo (#1)
- Loading branch information
Showing
6 changed files
with
731 additions
and
2 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,65 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Node template | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
demo/testConfig.js | ||
|
||
.idea | ||
.DS_Store | ||
|
||
# suitestrc | ||
.suitestrc |
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,11 @@ | ||
{ | ||
"username": "", | ||
"password": "", | ||
"orgId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"deviceId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"appConfigId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
|
||
"tokenKey": "xxxxxxxxxx", | ||
"tokenPassword": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", | ||
"testPackId": 1111 | ||
} |
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 |
---|---|---|
@@ -1,2 +1,46 @@ | ||
# suitest-js-api-mocha-demo | ||
Demo application on how to use Suitest JS API with Mocha test runner | ||
# Suitest JavaScript API demo - Mocha integration | ||
|
||
This repository holds a minimal set-up, required to launch [Suitest JS API](https://github.com/SuitestAutomation/suitest-js-api) e2e tests with [Mocha test runner](https://github.com/mochajs/mocha). | ||
|
||
## Demo set up for Suitest JS API with Mocha test runner | ||
|
||
1. Copy `.suitestrc.dist` file as `.suitestrc` and fill in it's contents | ||
with your values according to [documentation](https://suite.st/docs/suitest-api/setup/#environment-setup). | ||
2. Write your tests in `test/` folder. There is an example in `test/dummy.test.js`. | ||
3. In terminal run `yarn` or `npm i`. | ||
4. Run `yarn run interactive` or `npm run interactive` for interactive mode or | ||
`yarn run automated` or `npm run automated` for automated. | ||
|
||
## Debugging tests with IDE | ||
|
||
**Webstorm** | ||
Create `Node.js` configuration where | ||
1. _Working directory_ path to project root folder. | ||
2. _JavaScript file_ `./node_modules/.bin/suitest`. | ||
3. _Application parameters_ `interactive --inspect-brk=[available port for debugger] ./node_modules/.bin/_mocha --no-timeouts --exit`. | ||
|
||
**VS code** | ||
Debug config can be like: | ||
``` | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Any config name", | ||
"program": "${workspaceFolder}/node_modules/.bin/suitest", | ||
"args": [ | ||
"interactive", | ||
"--inspect-brk=9121", | ||
"./node_modules/.bin/_mocha", | ||
"--no-timeouts", | ||
"--exit" | ||
], | ||
"cwd": "${workspaceFolder}", | ||
"autoAttachChildProcesses": true | ||
} | ||
``` | ||
|
||
## Debugging test with chrome devtools | ||
|
||
1. Run `npm run debug`. | ||
2. Open `http://localhost:[port]/json/list`. | ||
3. Visit path specified in `devtoolsFrontendUrl`. |
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,14 @@ | ||
{ | ||
"name": "suitest-js-api-mocha-demo", | ||
"version": "1.0.0", | ||
"description": "Demo set up for Suitest JS API", | ||
"dependencies": { | ||
"mocha": "^5.0.4", | ||
"suitest-js-api": "^1.2.1" | ||
}, | ||
"scripts": { | ||
"interactive": "suitest interactive mocha --no-timeouts --exit", | ||
"debug": "suitest interactive --inspect-brk=9121 ./node_modules/.bin/_mocha --no-timeouts --exit", | ||
"automated": "suitest automated mocha --no-timeouts --exit" | ||
} | ||
} |
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,37 @@ | ||
const suitest = require('suitest-js-api'); | ||
const {assert} = suitest; | ||
|
||
describe('My super cool test', () => { | ||
before(async() => { | ||
try { | ||
// Start test | ||
await suitest.startTest('my-super-cool-test'); | ||
} catch (e) { | ||
console.error(e); | ||
// Mocha wouldn't stop if just throw an error here | ||
process.exit(1); | ||
} | ||
}); | ||
|
||
it('should pass', async() => { | ||
// Open app | ||
await assert.openApp(); | ||
|
||
// assert location | ||
await assert.location().doesNot().startWith('test'); | ||
|
||
// assert cookie | ||
await assert.cookie('name').doesNot().exist(); | ||
|
||
// test element | ||
await assert.element({ | ||
css: 'div', | ||
index: 1, | ||
}).exist(); | ||
}); | ||
|
||
after(async() => { | ||
// End test | ||
await suitest.endTest(); | ||
}); | ||
}); |
Oops, something went wrong.