add nightwatch (#763)
This commit is contained in:
Родитель
4a2996087e
Коммит
df979a42a2
|
@ -184,3 +184,4 @@ dist/
|
|||
# Misc
|
||||
statistics.html
|
||||
npm
|
||||
tests_output
|
||||
|
|
|
@ -26,13 +26,10 @@
|
|||
'qunit',
|
||||
'node_modules/@microsoft/applicationinsights-core-js/browser/applicationinsights-core-js',
|
||||
], function(QUnit, core) {
|
||||
console.log('core', core);
|
||||
console.log('Qunit', QUnit);
|
||||
define('@microsoft/applicationinsights-core-js', function(){return core;})
|
||||
require([
|
||||
'node_modules/@microsoft/applicationinsights-common/browser/applicationinsights-common'
|
||||
], function(common) {
|
||||
console.log('common', common);
|
||||
define('@microsoft/applicationinsights-common', common);
|
||||
require([
|
||||
'node_modules/@microsoft/applicationinsights-analytics-js/browser/applicationinsights-analytics-js',
|
||||
|
@ -40,10 +37,6 @@
|
|||
'node_modules/@microsoft/applicationinsights-properties-js/browser/applicationinsights-properties-js',
|
||||
'node_modules/@microsoft/applicationinsights-dependencies-js/browser/applicationinsights-dependencies-js'
|
||||
], function(analytics, channel, properties, dependencies) {
|
||||
console.log('analytics', analytics);
|
||||
console.log('channel', channel);
|
||||
console.log('properties', properties);
|
||||
console.log('dependencies', dependencies);
|
||||
define('@microsoft/applicationinsights-analytics-js', function(){return analytics;});
|
||||
define('@microsoft/applicationinsights-channel-js', function() {return channel;});
|
||||
define('@microsoft/applicationinsights-properties-js', function() {return properties;});
|
||||
|
@ -59,13 +52,6 @@
|
|||
});
|
||||
});
|
||||
});
|
||||
// require(['Tests/Selenium/appinsights-sdk.tests'],
|
||||
// function (tests) {
|
||||
// console.log('tests:', tests);
|
||||
// },
|
||||
// function (err) {
|
||||
// console.log(err);
|
||||
// });
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
require('nightwatch/bin/runner.js');
|
|
@ -0,0 +1,137 @@
|
|||
{
|
||||
"src_folders" : ["Tests/nightwatch"],
|
||||
"webdriver" : {
|
||||
"start_process": true,
|
||||
"port": 4444
|
||||
},
|
||||
|
||||
"test_settings" : {
|
||||
"chrome": {
|
||||
"output_folder": "tests_output/chrome",
|
||||
"webdriver": {
|
||||
"port": 9515,
|
||||
"server_path": "node_modules/chromedriver/lib/chromedriver/chromedriver",
|
||||
"cli_args": [
|
||||
"--verbose"
|
||||
]
|
||||
},
|
||||
"desiredCapabilities": {
|
||||
"browserName": "chrome",
|
||||
"chromeOptions": {
|
||||
"args": [
|
||||
"--no-sandbox"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"firefox": {
|
||||
"output_folder": "tests_output/firefox",
|
||||
"webdriver": {
|
||||
"start_process": true,
|
||||
"port": 9516,
|
||||
"server_path": "node_modules/geckodriver/geckodriver",
|
||||
"cli_args": [
|
||||
"--log",
|
||||
"debug"
|
||||
]
|
||||
},
|
||||
"desiredCapabilities": {
|
||||
"browserName": "firefox",
|
||||
"acceptInsecureCerts": true
|
||||
}
|
||||
},
|
||||
"edge": {
|
||||
"output_folder": "tests_output/edge",
|
||||
"selenium_host": "127.0.0.1",
|
||||
"selenium_port": 9517,
|
||||
"selenium": {
|
||||
"start_process": true,
|
||||
"server_path": "node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.5.jar",
|
||||
"log_path": "",
|
||||
"cli_args": {
|
||||
"webdriver.edge.driver": "C:/Windows/System32/MicrosoftWebDriver.exe"
|
||||
}
|
||||
},
|
||||
"desiredCapabilities": {
|
||||
"browserName": "MicrosoftEdge",
|
||||
"acceptSslCerts": true
|
||||
}
|
||||
},
|
||||
"ie11": {
|
||||
"output_folder": "tests_output/ie11",
|
||||
"selenium_host": "127.0.0.1",
|
||||
"selenium_port": 9518,
|
||||
"selenium": {
|
||||
"start_process": true,
|
||||
"silent": true,
|
||||
"server_path": "node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.5.jar",
|
||||
"cli_args": {
|
||||
"webdriver.ie.driver": "./bin/IEDriverServer.exe"
|
||||
}
|
||||
},
|
||||
"desiredCapabilities": {
|
||||
"browserName": "internet explorer",
|
||||
"version": 11,
|
||||
"javascriptEnabled": true,
|
||||
"acceptSslCerts": true
|
||||
}
|
||||
},
|
||||
"ie10": {
|
||||
"output_folder": "tests_output/ie10",
|
||||
"selenium_host": "127.0.0.1",
|
||||
"selenium_port": 9519,
|
||||
"selenium": {
|
||||
"start_process": true,
|
||||
"silent": true,
|
||||
"server_path": "node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.5.jar",
|
||||
"cli_args": {
|
||||
"webdriver.ie.driver": "./bin/IEDriverServer.exe"
|
||||
}
|
||||
},
|
||||
"desiredCapabilities": {
|
||||
"browserName": "internet explorer",
|
||||
"version": 10,
|
||||
"javascriptEnabled": true,
|
||||
"acceptSslCerts": true
|
||||
}
|
||||
},
|
||||
"ie9": {
|
||||
"output_folder": "tests_output/ie9",
|
||||
"selenium_host": "127.0.0.1",
|
||||
"selenium_port": 9520,
|
||||
"selenium": {
|
||||
"start_process": true,
|
||||
"silent": true,
|
||||
"server_path": "node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.5.jar",
|
||||
"cli_args": {
|
||||
"webdriver.ie.driver": "./bin/IEDriverServer.exe"
|
||||
}
|
||||
},
|
||||
"desiredCapabilities": {
|
||||
"browserName": "internet explorer",
|
||||
"version": 9,
|
||||
"javascriptEnabled": true,
|
||||
"acceptSslCerts": true
|
||||
}
|
||||
},
|
||||
"ie8": {
|
||||
"output_folder": "tests_output/ie8",
|
||||
"selenium_host": "127.0.0.1",
|
||||
"selenium_port": 9521,
|
||||
"selenium": {
|
||||
"start_process": true,
|
||||
"silent": true,
|
||||
"server_path": "node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.5.jar",
|
||||
"cli_args": {
|
||||
"webdriver.ie.driver": "./bin/IEDriverServer.exe"
|
||||
}
|
||||
},
|
||||
"desiredCapabilities": {
|
||||
"browserName": "internet explorer",
|
||||
"version": 8,
|
||||
"javascriptEnabled": true,
|
||||
"acceptSslCerts": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
module.exports = {
|
||||
'1. Navigate to tests' : function (browser) {
|
||||
var reportName = `tests_output/qunit_output_${browser.options.desiredCapabilities.browserName}${browser.options.desiredCapabilities.version || ''}.html`;
|
||||
var ieAppendage = browser.options.desiredCapabilities.version;
|
||||
ieAppendage = ieAppendage ? `?version=${ieAppendage}` : '';
|
||||
browser
|
||||
.url(`http://localhost:8000/Tests/Selenium/Tests.html${ieAppendage}`)
|
||||
.pause(1500);
|
||||
|
||||
var pollResults = () => {
|
||||
try {
|
||||
browser.elements('css selector', 'li[class*="fail"] [class*="test-name"]', (result) => {
|
||||
if (result.value && result.value.length > 0) {
|
||||
browser.getTitle(title => {
|
||||
if (title.includes('✖')) {
|
||||
saveHtml(browser, reportName);
|
||||
clearTimeout(a);
|
||||
browser.assert.ok(false, 'Tests failed');
|
||||
browser.end();
|
||||
} else {
|
||||
a = setTimeout(pollResults, 1000);
|
||||
browser.pause(1500);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
browser.elements('css selector', 'li[class*="running"] [class*="test-name"]', (result) => {
|
||||
if (result.value && result.value.length === 0) {
|
||||
browser.getTitle(title => {
|
||||
if (title.includes('✔')) {
|
||||
saveHtml(browser, reportName);
|
||||
clearTimeout(a);
|
||||
browser.assert.ok(true, 'Tests passed');
|
||||
browser.end();
|
||||
} else {
|
||||
a = setTimeout(pollResults, 1000);
|
||||
browser.pause(1500);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
a = setTimeout(pollResults, 1000);
|
||||
browser.pause(1500);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
browser.assert.ok(false, 'Tests failed due to error');
|
||||
browser.end();
|
||||
}
|
||||
};
|
||||
var a = setTimeout(pollResults, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
function saveHtml(browser, reportName) {
|
||||
browser.source(result => {
|
||||
require('fs').writeFile(reportName, result.value);
|
||||
})
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
var http = require('http');
|
||||
var fs = require('fs');
|
||||
var crypto = require('crypto');
|
||||
|
||||
var finalhandler = require('finalhandler');
|
||||
var serveStatic = require('serve-static');
|
||||
|
||||
var PORT = process.env.PORT || 8000;
|
||||
var serve = serveStatic(__dirname + "/../../");
|
||||
var server = http.createServer(function(req, res) {
|
||||
var url = req.url;
|
||||
|
||||
// Kill the server
|
||||
if (url === '/_done') {
|
||||
console.log('Exiting server_nightwatch.js');
|
||||
res.write('<h1>Exiting</h1>');
|
||||
res.end();
|
||||
process.nextTick(() => {process.exit()});
|
||||
|
||||
// Special case - Add Internet Explorer emulation meta tag if query arg is present
|
||||
} else if (url.startsWith('/Tests/Selenium/Tests.html?')) {
|
||||
fs.readFile('Tests/Selenium/Tests.html', 'utf8', (err, html) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
// Grab version from query params and insert emulation meta tag into html
|
||||
var version = parseInt(url.substring('version='.length+url.indexOf('version=')));
|
||||
var ieEmulationMetaTag = `<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE${version}" />`;
|
||||
var insertAfter = html.indexOf('<head>') + '<head>'.length;
|
||||
html = html.substr(0, insertAfter) + ieEmulationMetaTag + html.substr(insertAfter);
|
||||
|
||||
// Send new html
|
||||
res.writeHeader(200, {'Content-Type': 'text/html'});
|
||||
res.write(html);
|
||||
res.end();
|
||||
});
|
||||
|
||||
// Serve static files normally
|
||||
} else {
|
||||
var done = finalhandler(req, res);
|
||||
serve(req, res, done);
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`Now listening at https://localhost:${PORT}}`)
|
||||
server.listen(PORT);
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -11,12 +11,26 @@
|
|||
"build": "npm run build:esm && npm run build:browser && grunt snippetvnext",
|
||||
"build:esm": "grunt aisku",
|
||||
"build:browser": "rollup -c",
|
||||
"test": "grunt aiskutests"
|
||||
"test": "grunt aiskutests",
|
||||
"nightwatch:chrome": "nightwatch -c Tests/nightwatch/nightwatch.json Tests/nightwatch/run_nightwatch.js --env chrome",
|
||||
"nightwatch:firefox": "nightwatch -c Tests/nightwatch/nightwatch.json Tests/nightwatch/run_nightwatch.js --env firefox",
|
||||
"nightwatch:edge": "nightwatch -c Tests/nightwatch/nightwatch.json Tests/nightwatch/run_nightwatch.js --env edge",
|
||||
"nightwatch:ie8": "nightwatch -c Tests/nightwatch/nightwatch.json Tests/nightwatch/run_nightwatch.js --env ie8",
|
||||
"nightwatch:ie9": "nightwatch -c Tests/nightwatch/nightwatch.json Tests/nightwatch/run_nightwatch.js --env ie9",
|
||||
"nightwatch:ie10": "nightwatch -c Tests/nightwatch/nightwatch.json Tests/nightwatch/run_nightwatch.js --env ie10",
|
||||
"nightwatch:ie11": "nightwatch -c Tests/nightwatch/nightwatch.json Tests/nightwatch/run_nightwatch.js --env ie11",
|
||||
"nightwatch": "start node Tests/nightwatch/serve_nightwatch.js && npx concurrently \"npm run nightwatch:chrome\" \"npm run nightwatch:ie11\" \"npm run nightwatch:ie10\" && npm run nightwatch:done || npm run nightwatch:done",
|
||||
"nightwatch:done": "curl http://localhost:8000/_done"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chromedriver": "^2.45.0",
|
||||
"finalhandler": "^1.1.1",
|
||||
"geckodriver": "^1.14.1",
|
||||
"rollup-plugin-node-resolve": "^3.4.0",
|
||||
"rollup-plugin-replace": "^2.1.0",
|
||||
"rollup-plugin-uglify": "^6.0.0",
|
||||
"selenium-server-standalone-jar": "^3.141.5",
|
||||
"serve-static": "^1.13.2",
|
||||
"source-map-loader": "^0.2.3",
|
||||
"typescript": "2.5.3"
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче