Ver a proveniência

write some tests

bubble
RVKen há 7 anos
ascendente
cometimento
d53a139e9c
6 ficheiros alterados com 113 adições e 33 eliminações
  1. +7
    -0
      README.md
  2. +2
    -1
      package.json
  3. +1
    -1
      test/e2e/nightwatch.json
  4. +26
    -0
      test/e2e/pages/main.js
  5. +77
    -0
      test/e2e/scenarios/initial-render/test.js
  6. +0
    -31
      test/e2e/scenarios/test.js

+ 7
- 0
README.md Ver ficheiro

@@ -56,6 +56,13 @@ If you'd like to make modifications to the codebase, run the dev server with: `n

If you'd like to rebuild the `/dist` folder with your codebase changes, run `npm run build`.


##### Integrate Tests

You will need JDK of version 7 or higher as instructed here
http://nightwatchjs.org/gettingstarted#selenium-server-setup


##### Browser support
Swagger UI works in the latest versions of Chrome, Safari, Firefox, Edge and IE11.



+ 2
- 1
package.json Ver ficheiro

@@ -33,7 +33,8 @@
"test-in-node": "npm run lint-errors && npm run just-test-in-node",
"just-test": "karma start --config karma.conf.js",
"just-test-in-node": "mocha --recursive --compilers js:babel-core/register test/core test/components test/bugs test/swagger-ui-dist-package",
"e2e": "nightwatch test/e2e/scenarios --config test/e2e/nightwatch.json --verbose"
"e2e": "nightwatch test/e2e/scenarios --config test/e2e/nightwatch.json --verbose",
"e2e-initial-render": "nightwatch test/e2e/scenarios --config test/e2e/nightwatch.json --group initial-render"
},
"dependencies": {
"babel-polyfill": "^6.23.0",


+ 1
- 1
test/e2e/nightwatch.json Ver ficheiro

@@ -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
- 0
test/e2e/pages/main.js Ver ficheiro

@@ -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
- 0
test/e2e/scenarios/initial-render/test.js Ver ficheiro

@@ -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()
})
})
})

+ 0
- 31
test/e2e/scenarios/test.js Ver ficheiro

@@ -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')
})
})
})

Carregando…
Cancelar
Guardar