Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nightwatch.js: Use plugin nightwatch-helpers
- Loading branch information
1 parent
97a75d7
commit ac78a05
Showing
6 changed files
with
58 additions
and
16 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,32 +1,25 @@ | ||
module.exports = {}; | ||
|
||
function test(name, cb) { | ||
module.exports[name] = cb; | ||
} | ||
const { afterEach, beforeEach, test } = require('../helpers/')(module); | ||
|
||
const PAGE_URL = 'https://piecioshka.pl/blog'; | ||
const PAGE_LOAD_DELAY = 3000; | ||
|
||
async function setup(client) { | ||
beforeEach(async (client) => { | ||
console.log('beforeEach'); | ||
await client.url(PAGE_URL); | ||
await client.waitForElementVisible('body', PAGE_LOAD_DELAY); | ||
} | ||
}); | ||
|
||
async function teardown(client) { | ||
// ... | ||
} | ||
afterEach(() => { | ||
console.log('afterEach'); | ||
}); | ||
|
||
test('Spr. czy istnieje avatar', async (client) => { | ||
await setup(client); | ||
await client.assert.elementPresent('#me img'); | ||
// await teardown(client); | ||
}); | ||
|
||
test('Spr. czy jest odpowiednia liczba elementów w menu', async (client) => { | ||
await setup(client); | ||
await client.elements('css selector', '.menu-item', (result) => { | ||
const menuSize = result.value.length; | ||
client.assert.equal(menuSize, 10); | ||
}); | ||
// await teardown(client); | ||
}); |
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,7 @@ | ||
const { test } = require('../helpers/')(module); | ||
|
||
test('Spr. czy istnieją wymagane paragrafy?', async (client) => { | ||
await client.url('http://example.org'); | ||
await client.waitForElementVisible('body'); | ||
await client.assert.count('p', 2); | ||
}); |
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,32 @@ | ||
function test(module) { | ||
return (name, cb) => { | ||
module.exports[name] = cb; | ||
} | ||
} | ||
|
||
function aspectize(name, mod) { | ||
return (cb) => { | ||
const previous = mod.exports[name]; | ||
mod.exports[name] = (client) => { | ||
if (typeof previous === 'function') { | ||
previous(client); | ||
} | ||
cb(client); | ||
}; | ||
} | ||
} | ||
|
||
function beforeEach(mod) { | ||
return aspectize('beforeEach', mod); | ||
} | ||
|
||
function afterEach(mod) { | ||
return aspectize('afterEach', mod); | ||
} | ||
|
||
module.exports = (mod) => ({ | ||
it: test(mod), | ||
test: test(mod), | ||
beforeEach: beforeEach(mod), | ||
afterEach: afterEach(mod), | ||
}); |