https://github.com/ysugimoto/nightwatchify
nightwatchify makes your ES6 code executable on nightwatch.js.
https://github.com/ysugimoto/nightwatchify
nightwatch nightwatchjs nodejs
Last synced: 3 months ago
JSON representation
nightwatchify makes your ES6 code executable on nightwatch.js.
- Host: GitHub
- URL: https://github.com/ysugimoto/nightwatchify
- Owner: ysugimoto
- License: mit
- Created: 2017-12-04T15:18:11.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-19T06:46:28.000Z (almost 8 years ago)
- Last Synced: 2025-02-26T11:05:10.738Z (7 months ago)
- Topics: nightwatch, nightwatchjs, nodejs
- Language: JavaScript
- Homepage:
- 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
# nightwatchify
`nightwatchify` makes your ES6 code executable on [nightwatch.js](http://nightwatchjs.org/).
## Usage
### nightwatchify(testcases)
Wrap nightwatch's testcases to ES5 testcase object
```js
const nightwatchify = require('nightwatchify');module.exports = nightwatchify({
'@tags': ['example'],
"Google"(client) {
client
.url('https://google.com')
.waitForElementVisible('body', 1000);
},afterEach(client, done) {
// do something
}
});
```### nightwatchify.Command
Wrap nightwatch's [Custom Commands](http://nightwatchjs.org/guide#writing-custom-commands) to executable by ES6 class.
This is example for Saucelabs update job:
```js
const nightwatchify = require('nightwatchify');
const Saucelabs = require('saucelabs');// Define as ES6 class
class SaucelabsReporter {
constructor() {
}command(callback) {
this.api.session(session => {
const s = new Saucelabs({
"username": "${SAUCE_USERNAME}",
"password": "${SAUCE_ACCESS_KEY}"
});
const test = this.api.currentTest;
s.updateJob(session.sessionId, {
passed: test.failed === 0,
name: `${test.name}: ${test.module}`
}, () => {
this.emit('complete');
if (callback) {
callback.call(this.client.api);
}
});
});return this;
}
}module.exports = nightwatchify.Command(SaucelabsReporter);
```The wrapped class extends `EventEmitter` automatically, so you can use `this.emit('complete')` without any extends.
__Note__: context of `command()` method is wrapped class, not `SaucelabsReporter`. If you want to access `SaucelabsReporter` instance itself, you can access it via `this.cmd` property.
### nightwatchify.Bdd()
Wrap BDD global functions to ES5
```js
const nightwatchify = require('nightwatchify');
nightwatchify.Bdd();describe('Google', () => {
it('Index', client => {
client
.url('https://google.com')
.waitForElementVisible('body', 1000);
});afterEach((client, done) => {
// do something
});
});
```## Author
Yoshiaki Sugimoto
## License
MIT