updated test to check console errors after loading
This commit is contained in:
@@ -27,10 +27,9 @@ var driver = new webdriver.Builder().
|
|||||||
* Checks console errors and fails if there is any error
|
* Checks console errors and fails if there is any error
|
||||||
* Note: It's a good idea to run this after each operation
|
* Note: It's a good idea to run this after each operation
|
||||||
*/
|
*/
|
||||||
function checkConsoleErros () {
|
function checkConsoleErrors () {
|
||||||
it('should not have any console errors', function (done) {
|
it('should not have any console errors', function (done) {
|
||||||
driver.manage().logs().get('browser').then(function(browserLogs) {
|
driver.manage().logs().get('browser').then(function(browserLogs) {
|
||||||
|
|
||||||
var errors = [];
|
var errors = [];
|
||||||
|
|
||||||
browserLogs.forEach(function(log){
|
browserLogs.forEach(function(log){
|
||||||
@@ -41,7 +40,6 @@ function checkConsoleErros () {
|
|||||||
errors.push(log);
|
errors.push(log);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(errors).to.be.empty;
|
expect(errors).to.be.empty;
|
||||||
|
|
||||||
done();
|
done();
|
||||||
@@ -49,35 +47,30 @@ function checkConsoleErros () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('basics', function () {
|
describe('basics', function (done) {
|
||||||
|
|
||||||
this.timeout(10 * 1000);
|
this.timeout(10 * 1000);
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
driver.get('http://localhost:' + PORT);
|
driver.get('http://localhost:' + PORT + '/index.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have "Swagger UI" in title', function (done) {
|
it('should have "Swagger UI" in title', function (done) {
|
||||||
|
|
||||||
driver.wait(function() {
|
driver.wait(function() {
|
||||||
return driver.getTitle().then(function(title) {
|
return driver.getTitle().then(function(title) {
|
||||||
var hasTitle = title.indexOf('Swagger UI') > -1;
|
var hasTitle = title.indexOf('Swagger UI') > -1;
|
||||||
|
|
||||||
if (hasTitle) {
|
if (hasTitle) {
|
||||||
expect(title).to.contain('Swagger UI');
|
expect(title).to.contain('Swagger UI');
|
||||||
|
checkConsoleErrors();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasTitle;
|
return hasTitle;
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
checkConsoleErros();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('cleanup', function () {
|
describe('cleanup', function () {
|
||||||
|
|
||||||
it('kills the static server', function () {
|
it('kills the static server', function () {
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
@@ -86,6 +79,3 @@ describe('cleanup', function () {
|
|||||||
driver.quit();
|
driver.quit();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<!DOCTYPE HTML>
|
|
||||||
<head>
|
|
||||||
<title>swagger-ui specs</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../../lib/jasmine-1.1.0/jasmine.css">
|
|
||||||
|
|
||||||
<script src="http://code.jquery.com/jquery.min.js"></script>
|
|
||||||
<script type="text/javascript" src="../../lib/jasmine-1.1.0/jasmine.js"></script>
|
|
||||||
<script type="text/javascript" src="../../lib/jasmine-1.1.0/jasmine-html.js"></script>
|
|
||||||
|
|
||||||
<!-- source first, then spec -->
|
|
||||||
<script type="text/javascript" src="../../lib/swagger-ui.js"></script>
|
|
||||||
<script type="text/javascript" src="../../lib/swagger-ui-spec.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(function() {
|
|
||||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
|
||||||
jasmine.getEnv().execute();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div id="swagger_ui"></div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user