Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Setting saucelabs to work with netlify configuration
Browse files Browse the repository at this point in the history
configuration for ie11 is defined but not including it right now
on tests because ie11 is still not working on project
  • Loading branch information
guergana committed Nov 12, 2020
1 parent 11d276a commit 16e7146
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .env.example
@@ -1,2 +1,6 @@
# The port for the development server
PORT=8080

#Saucelabs access data - needed if testing from local-cli
SAUCE_USERNAME='<username>'
SAUCE_ACCESS_KEY='<access_key>'
37 changes: 37 additions & 0 deletions .github/workflows/test-and-netlify.yml
@@ -0,0 +1,37 @@
# This workflow will do
# - a clean install of node dependencies
# - run tests
# - build and upload the storybook to a staging area
#
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

on: [push]

name: Test and deploy to netlify
jobs:
test-and-dev-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Install
run: npm ci
- name: Test
run: npm run test
- name: Build Project
run: npm run build
- name: Deploy to netlify
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: echo "DEPLOY_URL=$(npm run --silent netlify | jq '.deploy_url' --raw-output)" >> $GITHUB_ENV
id: "deploy"
- name: Run e2e cross browser tests
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
run: npm run e2e:saucelabs
61 changes: 60 additions & 1 deletion nightwatch.conf.js
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/camelcase */
const build = `Nightwatch build-${process.env.DATE}`;

/* eslint-disable @typescript-eslint/camelcase */
module.exports = {
src_folders: [ 'tests/e2e/specs' ],
page_objects_path: '',
Expand Down Expand Up @@ -27,5 +28,63 @@ module.exports = {
},
},
},

sauceLabs: {
launch_url: `${process.env.DEPLOY_URL}`,
isLocal: false,
selenium_host: 'ondemand.saucelabs.com',
selenium_port: 80,
username: process.env.SAUCE_USERNAME,
access_key: process.env.SAUCE_ACCESS_KEY,
desiredCapabilities: {
build,
screenResolution: '1600x1200',
seleniumVersion: '3.141.59',
},
},
sauceChrome: {
extends: 'sauceLabs',
desiredCapabilities: {
browserName: 'googlechrome',
platform: 'Windows 10',
version: 'latest',
},
},

sauceFirefox: {
extends: 'sauceLabs',
desiredCapabilities: {
browserName: 'firefox',
platform: 'Windows 10',
version: 'latest',
},
},

sauceIE: {
extends: 'sauceLabs',
desiredCapabilities: {
browserName: 'internet explorer',
platform: 'Windows 10',
version: 'latest',
},
},

sauceEdge: {
extends: 'sauceLabs',
desiredCapabilities: {
browserName: 'MicrosoftEdge',
platform: 'Windows 10',
version: 'latest',
},
},

sauceSafari: {
extends: 'sauceLabs',
desiredCapabilities: {
browserName: 'safari',
platform: 'macOS 10.15',
version: 'latest',
},
},
},
};
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -7,7 +7,7 @@
"name": "The Wikidata team"
},
"scripts": {
"e2e": "vue-cli-service test:e2e",
"e2e:saucelabs": "env DATE=\"$(date)\" nightwatch --config nightwatch.conf.js --env sauceChrome,sauceFirefox,sauceEdge,sauceSafari",
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
Expand All @@ -16,7 +16,7 @@
"test:lintcss": "stylelint '**/*.vue'",
"fix:css": "stylelint '**/*.vue' --fix",
"fix:ts": "vue-cli-service lint",
"netlify": "npx netlify deploy --dir=dist"
"netlify": "npx netlify deploy --dir=dist --json"
},
"main": "index.js",
"dependencies": {
Expand Down
23 changes: 23 additions & 0 deletions tests/e2e/globals.js
@@ -1,3 +1,6 @@
const SauceLabs = require( 'saucelabs' ).default;
const account = new SauceLabs( { user: process.env.SAUCE_USERNAME, key: process.env.SAUCE_ACCESS_KEY } );

module.exports = {
// this controls whether to abort the test execution when an assertion failed and skip the rest
// it's being used in waitFor commands and expect assertions
Expand All @@ -14,4 +17,24 @@ module.exports = {
connectionRetryTimeout: 90000,
connectionRetryCount: 3,

// Pass information about the browser tests to SauceLabs
afterEach( client, done ) {
if ( !this.isLocal ) {
const sessionId = client.sessionId;
const results = client.currentTest.results;
const testPassed = results.passed === results.tests;
client.end( function () {
account.updateJob(
process.env.SAUCE_USERNAME,
sessionId,
{
tags: [ 'QueryBuilder' ],
passed: testPassed,
},
);
done();
} );
}
},

};

0 comments on commit 16e7146

Please sign in to comment.