Compare commits

...

1 Commits

Author SHA1 Message Date
Jesse Mazzella
0b9acbf58e Enable 'no-console' eslint rule, create helper logging function 2022-06-06 11:43:13 -07:00
4 changed files with 55 additions and 9 deletions

View File

@@ -241,7 +241,7 @@ module.exports = {
],
"vue/max-attributes-per-line": ["error", {
"singleline": 1,
"multiline": 1,
"multiline": 1
}],
"vue/first-attribute-linebreak": "error",
"vue/multiline-html-element-content-newline": "off",
@@ -266,6 +266,12 @@ module.exports = {
"no-var": "off",
"one-var": "off"
}
},
{
"files": ["**/*.e2e.spec.js", "**/*.visual.spec.js"],
"rules": {
"no-console": "warn"
}
}
]
};

View File

@@ -25,3 +25,43 @@ exports.test = base.test.extend({
}
});
/**
* Generic console logging function for use in tests.
* @param {'log'|'info'|'warn'|'debug'|'error'} [severity='log'] - The severity of the message.
* @param {...any} args
*/
function log(severity, ...args) {
const logTypes = ['log', 'info', 'warn', 'debug', 'error'];
let logFn;
// Default to log level severity if not provided
if (!logTypes.includes(severity)) {
args.unshift(severity);
severity = 'log';
}
switch (severity) {
case 'log':
logFn = console.log;
break;
case 'info':
logFn = console.info;
break;
case 'warn':
logFn = console.warn;
break;
case 'debug':
logFn = console.debug;
break;
case 'error':
logFn = console.error;
break;
default:
logFn = console.log;
break;
}
logFn(`${severity.toUpperCase()}:`, ...args);
}
exports.log = log;

View File

@@ -26,7 +26,7 @@ suite is sharing state between tests which is considered an anti-pattern. Implim
demonstrate some playwright for test developers. This pattern should not be re-used in other CRUD suites.
*/
const { test } = require('../../../fixtures.js');
const { test, log } = require('../../../fixtures.js');
const { expect } = require('@playwright/test');
let conditionSetUrl;
@@ -56,10 +56,10 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => {
//Set object identifier from url
conditionSetUrl = await page.url();
console.log('conditionSetUrl ' + conditionSetUrl);
log('conditionSetUrl ' + conditionSetUrl);
getConditionSetIdentifierFromUrl = await conditionSetUrl.split('/').pop().split('?')[0];
console.debug('getConditionSetIdentifierFromUrl ' + getConditionSetIdentifierFromUrl);
log('debug', 'getConditionSetIdentifierFromUrl ' + getConditionSetIdentifierFromUrl);
});
test.afterAll(async ({ browser }) => {
await browser.close();

View File

@@ -26,7 +26,7 @@ but only assume that example imagery is present.
*/
/* globals process */
const { test } = require('../../../fixtures.js');
const { test, log } = require('../../../fixtures.js');
const { expect } = require('@playwright/test');
test.describe('Example Imagery', () => {
@@ -101,9 +101,9 @@ test.describe('Example Imagery', () => {
await page.mouse.move(imageCenterX, imageCenterY);
//Get Diagnostic info about process environment
console.log('process.platform is ' + process.platform);
log('process.platform is ' + process.platform);
const getUA = await page.evaluate(() => navigator.userAgent);
console.log('navigator.userAgent ' + getUA);
log('navigator.userAgent ' + getUA);
// Pan Imagery Hints
const expectedAltText = process.platform === 'linux' ? 'Ctrl+Alt drag to pan' : 'Alt drag to pan';
const imageryHintsText = await page.locator('.c-imagery__hints').innerText();
@@ -347,7 +347,7 @@ test('Example Imagery in Display layout', async ({ page }) => {
return window.getComputedStyle(el).getPropertyValue('background-image').match(/url\(([^)]+)\)/)[1];
});
let backgroundImageUrl1 = backgroundImageUrl.slice(1, -1); //forgive me, padre
console.log('backgroundImageUrl1 ' + backgroundImageUrl1);
log('backgroundImageUrl1 ' + backgroundImageUrl1);
let backgroundImageUrl2;
await expect.poll(async () => {
@@ -362,7 +362,7 @@ test('Example Imagery in Display layout', async ({ page }) => {
message: "verify next image has updated",
timeout: 6 * 1000
}).not.toBe(backgroundImageUrl1);
console.log('backgroundImageUrl2 ' + backgroundImageUrl2);
log('backgroundImageUrl2 ' + backgroundImageUrl2);
});
test.describe('Example imagery thumbnails resize in display layouts', () => {