Skip to content

Commit

Permalink
test(ui): implement browser automation testing
Browse files Browse the repository at this point in the history
* initial prototype UI automated testing
  • Loading branch information
100stacks committed May 14, 2020
1 parent 2712358 commit c2faa40
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ notifications:
email: false
addons:
firefox: '61.0'
#sauce_connect: true
branch:
only:
- master
Expand All @@ -25,4 +24,13 @@ script:
- yarn lint
#- yarn test:coverage
- yarn generate
- yarn test
- yarn compile --prod
- if [[ "$TRAVIS_EVENT_TYPE" != false ]]; then
echo "Pull request detected. Running standard test suite first...";
yarn test;
echo "Running Sauce tests...";
yarn test:sauce || travis_terminate 1;
else
echo "Pull request was NOT detected. Running standard test suite...";
yarn test || travis_terminate 1;
fi
9 changes: 9 additions & 0 deletions karma-sauce-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @overview Karma SauceLabs start up script.
*
* Used to initialize minified HelixUI ES Modules for testing.
*/

import HelixUI from './dist/js/helix-ui.module.min.js';

HelixUI.initialize();
98 changes: 98 additions & 0 deletions karma.sauce.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/* eslint-env node */
const { createDefaultConfig } = require('@open-wc/testing-karma');
const merge = require('deepmerge');

const customLaunchers = {
win_edge_chromium: {
base: 'SauceLabs',
browserName: 'microsoftedge',
platform: 'Windows 10',
version: 'latest'
},
mac_chrome: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'OS X 10.13',
version: '80'
},
mac_firefox: {
base: 'SauceLabs',
browserName: 'firefox',
platform: 'OS X 10.13',
version: '75'
},
mac_safari: {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.13',
version: '13'
},
win_edge_legacy: {
base: 'SauceLabs',
browserName: 'microsoftedge',
platform: 'Windows 10',
version: '18.17763'
},
win_10_ie_11: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 10',
version: '11.285',
},
};

module.exports = config => {
config.set(
merge(createDefaultConfig(config), {
files: [
// runs all files ending with .test in the test folder,
// can be overwritten by passing a --grep flag. examples:
//
// npm run test -- --grep test/foo/bar.test.js
// npm run test -- --grep test/bar/*
{ pattern: 'karma-sauce-init.js',
type: 'module'
},
{ pattern: config.grep ? config.grep : 'src/elements/**/*.spec.js',
type: 'module'
},
],
// see the karma-esm docs for all options
esm: {
// if you are using 'bare module imports' you will need this option
nodeResolve: true,
compatibility: 'max',
moduleDirs: ['node_modules', 'dist'],
},
sauceLabs: {
testName: 'HelixUI Component Unit Tests',
public: "public restricted",
recordVideo: false,
// recordLogs: false,
},
customLaunchers: customLaunchers,
browsers: Object.keys(customLaunchers),
reporters: ['dots', 'saucelabs'],
singleRun: true,
browserDisconnectTimeout : 120000, // default 2000
browserDisconnectTolerance : 10, // default 0
browserNoActivityTimeout: 120000, // default 10000
captureTimeout: 120000, // default 60000
concurrency: 5,
client: {
mocha: {
timeout : 120000
}
},
polyfillsLoader: {
polyfills: {
webcomponents: true,
shadyCssCustomStyle: true,
},
},
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,
}),
);
return config;
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"jsdom": "^12.2.0",
"json5": "^2.1.3",
"karma": "5.0.2",
"karma-sauce-launcher": "~4.1.4",
"less": "^3.11.1",
"less-loader": "^5.0.0",
"lit-element": "^2.3.1",
Expand Down Expand Up @@ -94,6 +95,7 @@
"test:unit:deprecated": "mocha test/run_unit.js",
"test:deprecated": "cd test; yarn test",
"test": "karma start",
"test:sauce": "karma start karma.sauce.config.js",
"test:update": "karma start --update-snapshots",
"test:prune": "karma start --prune-snapshots",
"test:watch": "karma start --auto-watch=true --single-run=false"
Expand All @@ -114,6 +116,7 @@
"Evan Nabors",
"James Thompson",
"Lalith Karikelli",
"Nicko Winner-Arroyo",
"Shaleen Agarwal",
"Steven Salinas",
"Ty Taylor"
Expand Down

0 comments on commit c2faa40

Please sign in to comment.