diff --git a/bin/test.js b/bin/test.js deleted file mode 100644 index b9fb5a86..00000000 --- a/bin/test.js +++ /dev/null @@ -1,129 +0,0 @@ -import 'regenerator-runtime/runtime' -import path from 'path' -import dotenv from 'dotenv' -import { SpecReporter } from 'jasmine-spec-reporter' -import { getUUID } from '../packages/utils' - -dotenv.config() -const isLocal = process.env.NODE_ENV === 'test' -const username = process.env.SMARTBEAR_USER -const authKey = process.env.SMARTBEAR_AUTHKEY -const localIdentifier = getUUID() -const identifier = new Date().toLocaleString() -const specs = path.resolve(process.cwd(), `packages/*/*.test.${isLocal ? '' : 'cjs.'}js`) - -const commonCapabilities = { - username, - password: authKey, - record_video: true, - record_network: false, // there is an issue with CBT, forcing us not to record network p.t. - build: 'core-components tests' -} - -function completeCaps (caps) { - return caps.map((cap) => ({ - browserName: '', // TypeError: Target browser must be a string... - ...commonCapabilities, - ...cap - })) -} - -/** - * stripSensitiveValuesByKey replaces value of target key (e.g 'password') with a redacted value - * @param {Array} entryList List of key-value objects - * @param {String} key key to be replaced - * @returns {Array} entryList with replaced values (if any were found) - */ -function stripSensitiveValuesByKey (entryList, key) { - const VAL_REDACTED = '**Value redacted**' - return entryList.map(entry => Object.prototype.hasOwnProperty.call(entry, key) - ? ({ - ...entry, - [key]: VAL_REDACTED - }) - : entry) -} - -function config () { - console.log('isLocal?', isLocal) - console.log('capabilities:', stripSensitiveValuesByKey(capabilities, 'password')) - return { - framework: 'jasmine', - specs: [specs], - seleniumAddress: `http://${username}:${authKey}@hub.crossbrowsertesting.com:80/wd/hub`, - directConnect: isLocal, - SELENIUM_PROMISE_MANAGER: false, - jasmineNodeOpts: { - defaultTimeoutInterval: 20 * 1000, // 20 sek - print: Function.prototype // Disable dot reporter - }, - allScriptsTimeout: 30000, - getPageTimeout: 30000, - logLevel: 'INFO', - multiCapabilities: capabilities.map((cap) => { - return { - 'cbt.user': username, - 'cbt.key': authKey, - 'cbt.debug': false, // Capture screenshots for visual logs - 'cbt.record_video': false, // Capture video of tests - 'cbt.console': 'errors', // Capture console logs - 'cbt.localIdentifier': localIdentifier, - 'cbt.sendKeys': true, - project: 'core-components', - build: identifier, - name: ['core-components, ', - (cap.browserName || cap.device).replace(/./, (m) => m.toUpperCase()), - cap.browser_version ? parseInt(cap.browser_version) : '' - ].join(' '), - ...cap - } - }), - onPrepare: () => { - const env = jasmine.getEnv() - env.addReporter(new SpecReporter({ - spec: { - displaySuccessful: true, - displayFailed: true, - displayStacktrace: 'pretty', - displayErrorMessages: true - }, - summary: false - })) - browser.waitForAngularEnabled(false) - }, - onComplete: async (passed) => { - console.log('Test passed?', passed) - } - } -} -const capabilities = isLocal - ? [ - { - browserName: 'chrome', - chromeOptions: { - args: ['--headless', '--window-size=800x600'] - } - } - ] - : completeCaps([ - // Edge 18.18362, Windows 10, hits=218803, vdist=0.184 - // Edge 18.17763, Windows 10, hits=70727, vdist=0.178 - // Edge 18.18363, Windows 10, hits=15274, vdist=0.184 - // core-components - { - tags: { - id: 'edge', - browser: 'edge', - platform: 'windows', - device: 'desktop', - hits: 304804, - popularity: 'high', - default: true - }, - platform: 'Windows 10', - browserName: 'MicrosoftEdge', - version: '18' - } - ]) - -exports.config = config() diff --git a/package.json b/package.json index 67f55eb2..efa9df60 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "scripts": { "build": "rollup --config", "install": "node -r esm bin/index.js --install", - "postinstall": "webdriver-manager update", "outdated": "node -r esm bin/index.js --outdated", "publish:preminor": "node -r esm bin/index.js --publish=preminor", "publish:prepatch": "node -r esm bin/index.js --publish=prepatch", @@ -20,12 +19,11 @@ "publish:major": "node -r esm bin/index.js --publish=major", "start": "rollup --config --watch", "static-publish": "npm run build && static-publish --directory=packages --account=nrk-core --latest --major", - "test": "npm run build && npm run protractor && npm run lint", + "test": "npm run build && npx playwright test && npm run lint", "test-remote": "npm run build && npm run test-remote-run && npm run lint", "test-remote-run": "export NODE_ENV=test-remote; npm run protractor", "test-server": "npm run build && http-server ./packages -p 10003", - "lint": "standard -v", - "protractor": "node -r esm node_modules/.bin/protractor bin/test.js" + "lint": "standard -v" }, "devDependencies": { "@babel/core": "7.21.4", @@ -36,14 +34,10 @@ "@rollup/plugin-commonjs": "24.0.1", "@rollup/plugin-json": "6.0.0", "@rollup/plugin-node-resolve": "15.0.2", - "@webcomponents/custom-elements": "1.6.0", "dotenv": "16.0.3", "esm": "3.2.25", "fast-glob": "3.2.12", "http-server": "14.1.1", - "jasmine-spec-reporter": "7.0.0", - "protractor": "7.0.0", - "regenerator-runtime": "0.13.11", "rollup": "2.79.1", "rollup-plugin-serve": "2.0.2", "rollup-plugin-terser": "7.0.2", @@ -51,22 +45,7 @@ }, "standard": { "globals": [ - "HTMLElement", - "protractor", - "jasmine", - "describe", - "fdescribe", - "it", - "fit", - "expect", - "browser", - "$", - "$$", - "beforeEach", - "beforeAll", - "afterEach", - "afterAll", - "ExpectedConditions" + "HTMLElement" ] } } diff --git a/packages/test-utils.js b/packages/test-utils.js deleted file mode 100644 index 8469bf75..00000000 --- a/packages/test-utils.js +++ /dev/null @@ -1,11 +0,0 @@ -export function prop (selector, name) { - return browser.executeScript((selector, name) => { - return String((document.querySelector(selector) || {})[name]) - }, selector, name) -} - -export function attr (selector, name) { - return browser.executeScript((selector, name) => { - return String(document.querySelector(selector).getAttribute(name)) - }, selector, name) -}