mirror of
https://github.com/wassname/talk.git
synced 2026-07-01 10:02:43 +08:00
E2e with nightwatch and browserstack
This commit is contained in:
@@ -15,6 +15,8 @@ client/coral-framework/graphql/introspection.json
|
||||
*.DS_STORE
|
||||
|
||||
coverage/
|
||||
tests_output/
|
||||
local.log
|
||||
|
||||
plugins.json
|
||||
plugins/*
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
const nightwatch_config = {
|
||||
src_folders: './test/e2e/specs/',
|
||||
|
||||
selenium : {
|
||||
'start_process': false,
|
||||
'host': 'hub-cloud.browserstack.com',
|
||||
'port': 80
|
||||
},
|
||||
|
||||
test_settings: {
|
||||
default: {
|
||||
launch_url: process.env.E2E_LAUNCH_URL || 'http://localhost:3000',
|
||||
desiredCapabilities: {
|
||||
'browserstack.user': process.env.BROWSERSTACK_USER || 'coralproject2',
|
||||
'browserstack.key': process.env.BROWSERSTACK_KEY,
|
||||
'browserstack.local': true,
|
||||
'browser': 'chrome',
|
||||
'browserstack.debug': true,
|
||||
'browserstack.networkLogs': true,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Code to copy seleniumhost/port into test settings
|
||||
for(const i in nightwatch_config.test_settings){
|
||||
const config = nightwatch_config.test_settings[i];
|
||||
config['selenium_host'] = nightwatch_config.selenium.host;
|
||||
config['selenium_port'] = nightwatch_config.selenium.port;
|
||||
}
|
||||
|
||||
module.exports = nightwatch_config;
|
||||
+5
-2
@@ -15,6 +15,7 @@
|
||||
"lint": "yamllint locales/*.yml && eslint --ext=.js --ext=.json bin/* .",
|
||||
"lint-fix": "yarn lint --fix",
|
||||
"jest-watch": "TEST_MODE=unit NODE_ENV=test jest --watch",
|
||||
"e2e": "./scripts/e2e.js",
|
||||
"test": "TEST_MODE=unit NODE_ENV=test jest && TEST_MODE=unit NODE_ENV=test mocha -R ${MOCHA_REPORTER:-spec}",
|
||||
"test-cover": "TEST_MODE=unit NODE_ENV=test istanbul cover _mocha --report text --check-coverage -- -R spec",
|
||||
"heroku-postbuild": "./bin/cli plugins reconcile && yarn build",
|
||||
@@ -173,6 +174,7 @@
|
||||
"simplemde": "^1.11.2",
|
||||
"smoothscroll-polyfill": "^0.3.5",
|
||||
"snake-case": "^2.1.0",
|
||||
"snyk": "^1.42.5",
|
||||
"style-loader": "^0.16.0",
|
||||
"subscriptions-transport-ws": "^0.7.2",
|
||||
"timeago.js": "^2.0.3",
|
||||
@@ -185,14 +187,14 @@
|
||||
"webpack": "^2.3.1",
|
||||
"webpack-sources": "^1.0.1",
|
||||
"yaml-loader": "^0.4.0",
|
||||
"yamljs": "^0.2.10",
|
||||
"snyk": "^1.42.5"
|
||||
"yamljs": "^0.2.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@coralproject/eslint-config-talk": "^0.0.4",
|
||||
"babel-jest": "^21.2.0",
|
||||
"babel-plugin-dynamic-import-node": "^1.1.0",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
|
||||
"browserstack-local": "^1.3.0",
|
||||
"chai": "^3.5.0",
|
||||
"chai-as-promised": "^6.0.0",
|
||||
"chai-http": "^3.0.0",
|
||||
@@ -204,6 +206,7 @@
|
||||
"jest": "^21.2.1",
|
||||
"mocha": "^3.1.2",
|
||||
"mocha-junit-reporter": "^1.12.1",
|
||||
"nightwatch": "^0.9.16",
|
||||
"nodemon": "^1.11.0",
|
||||
"pre-git": "^3.15.3",
|
||||
"sinon": "^3.2.1",
|
||||
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const Nightwatch = require('nightwatch');
|
||||
const browserstack = require('browserstack-local');
|
||||
|
||||
try {
|
||||
const bs_local = new browserstack.Local();
|
||||
process.mainModule.filename = './node_modules/.bin/nightwatch';
|
||||
|
||||
// Code to start browserstack local before start of test
|
||||
console.log('Connecting local');
|
||||
Nightwatch.bs_local = bs_local;
|
||||
bs_local.start({'key': process.env.BROWSERSTACK_KEY}, function(error) {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
console.log('Connected. Now testing...');
|
||||
Nightwatch.cli(function(argv) {
|
||||
Nightwatch.CliRunner(argv)
|
||||
.setup(null, function(){
|
||||
|
||||
// Code to stop browserstack local after end of parallel test
|
||||
bs_local.stop(function(){});
|
||||
})
|
||||
.runTests(function(){
|
||||
|
||||
// Code to stop browserstack local after end of single test
|
||||
bs_local.stop(function(){});
|
||||
});
|
||||
});
|
||||
});
|
||||
} catch (ex) {
|
||||
console.log('There was an error while starting the test runner:\n\n');
|
||||
process.stderr.write(`${ex.stack}\n`);
|
||||
process.exit(2);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "@coralproject/eslint-config-talk",
|
||||
"rules": {
|
||||
"indent": "off"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
const uuid = require('uuid');
|
||||
const {murmur3} = require('murmurhash-js');
|
||||
|
||||
module.exports = {
|
||||
'Creates a new asset': (client) => {
|
||||
const assetTitle = `test@${murmur3(uuid.v4())}`;
|
||||
|
||||
client
|
||||
.url(`${client.launchUrl}/assets/title/${assetTitle}`)
|
||||
.assert.title(assetTitle)
|
||||
.waitForElementVisible('#coralStreamEmbed_iframe', 1000)
|
||||
.frame('coralStreamEmbed_iframe')
|
||||
.waitForElementVisible('.talk-stream-tab-container', 1000)
|
||||
.frameParent()
|
||||
.end();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user