write some tests
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
"live_output": true,
|
||||
"custom_commands_path" : "",
|
||||
"custom_assertions_path" : "",
|
||||
"page_objects_path" : "",
|
||||
"page_objects_path" : "test/e2e/pages",
|
||||
"globals_path" : "",
|
||||
"test_workers" : {
|
||||
"enabled" : true,
|
||||
|
||||
26
test/e2e/pages/main.js
Normal file
26
test/e2e/pages/main.js
Normal file
@@ -0,0 +1,26 @@
|
||||
module.exports = {
|
||||
sections: {
|
||||
topbar: {
|
||||
selector: ".topbar",
|
||||
elements: {
|
||||
inputBox: {
|
||||
selector: "input"
|
||||
},
|
||||
btnExplore: {
|
||||
selector: "button"
|
||||
}
|
||||
}
|
||||
},
|
||||
informationContainer: {
|
||||
selector: ".information-container",
|
||||
elements: {
|
||||
title: {
|
||||
selector: ".title"
|
||||
},
|
||||
version: {
|
||||
selector: ".version"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
77
test/e2e/scenarios/initial-render/test.js
Normal file
77
test/e2e/scenarios/initial-render/test.js
Normal file
@@ -0,0 +1,77 @@
|
||||
describe("initial render", function () {
|
||||
let mainPage
|
||||
|
||||
describe("for topbar", function () {
|
||||
let topbar
|
||||
before(function (client, done) {
|
||||
done()
|
||||
})
|
||||
|
||||
after(function (client, done) {
|
||||
client.end(function () {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function (client, done) {
|
||||
done()
|
||||
})
|
||||
|
||||
beforeEach(function (client, done) {
|
||||
mainPage = client
|
||||
.url("localhost:3200")
|
||||
.page.main()
|
||||
topbar = mainPage.section.topbar
|
||||
done()
|
||||
})
|
||||
|
||||
it("renders section", function (client) {
|
||||
mainPage.expect.section("@topbar").to.be.visible
|
||||
|
||||
client.end()
|
||||
})
|
||||
|
||||
it("renders input box", function (client) {
|
||||
topbar.expect.element("@inputBox").to.be.visible
|
||||
|
||||
client.end()
|
||||
})
|
||||
|
||||
it("renders explore button", function (client) {
|
||||
topbar.expect.element("@btnExplore").to.be.visible
|
||||
|
||||
client.end()
|
||||
})
|
||||
})
|
||||
|
||||
describe("for information", function () {
|
||||
let informationContainer
|
||||
beforeEach(function (client, done) {
|
||||
mainPage = client
|
||||
.url("localhost:3200")
|
||||
.page.main()
|
||||
informationContainer = mainPage.section.informationContainer
|
||||
done()
|
||||
})
|
||||
|
||||
it("renders section", function (client) {
|
||||
mainPage.expect.section("@informationContainer").to.be.visible.before(5000)
|
||||
|
||||
client.end()
|
||||
})
|
||||
|
||||
it("renders title", function (client) {
|
||||
// informationContainer.waitForElementVisible("@title", 5000, function() {
|
||||
// informationContainer.expect.element("@title").to.contain.text("Swagger Petstore")
|
||||
// informationContainer.expect.element("@version").to.contain.text("1.0.0")
|
||||
|
||||
// client.end()
|
||||
// })
|
||||
informationContainer.waitForElementVisible("@title", 5000)
|
||||
.assert.containsText("@title", "Swagger Petstore")
|
||||
.assert.containsText("@version", "1.0.0")
|
||||
|
||||
client.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,31 +0,0 @@
|
||||
describe('Google demo test for Mocha', function () {
|
||||
describe('with Nightwatch', function () {
|
||||
before(function (client, done) {
|
||||
done()
|
||||
})
|
||||
|
||||
after(function (client, done) {
|
||||
client.end(function () {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function (client, done) {
|
||||
done()
|
||||
})
|
||||
|
||||
beforeEach(function (client, done) {
|
||||
done()
|
||||
})
|
||||
|
||||
it('uses TDD to run the Google simple test', function (client) {
|
||||
client
|
||||
.url('http://google.com')
|
||||
.expect.element('body').to.be.present.before(1000)
|
||||
|
||||
client.setValue('input[type=text]', ['nightwatch', client.Keys.ENTER])
|
||||
.pause(1000)
|
||||
.assert.containsText('#main', 'Night Watch')
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user