Skip to content

Commit

Permalink
feat!: Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell committed Oct 15, 2023
1 parent 7a186fb commit c47f159
Show file tree
Hide file tree
Showing 10 changed files with 286 additions and 269 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on:
push:
branches:
- master

permissions:
contents: write
pull-requests: write

name: release-please

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: node
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install
Expand Down
12 changes: 6 additions & 6 deletions builder-chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import seleniumWebdriverIO from 'selenium-webdriver/io/index.js';
import platformBin from './platform-bin.js';

export default () => {
return new seleniumWebdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(new chrome.Options().headless())
.setChromeService(new chrome.ServiceBuilder(
seleniumWebdriverIO.findInPath(platformBin('chromedriver'))
));
return new seleniumWebdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(new chrome.Options().headless())
.setChromeService(new chrome.ServiceBuilder(
seleniumWebdriverIO.findInPath(platformBin('chromedriver'))
));
};
12 changes: 6 additions & 6 deletions builder-firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import seleniumWebdriverIO from 'selenium-webdriver/io/index.js';
import platformBin from './platform-bin.js';

export default () => {
return new seleniumWebdriver.Builder()
.forBrowser('firefox')
.setFirefoxOptions(new firefox.Options().headless())
.setFirefoxService(new firefox.ServiceBuilder(
seleniumWebdriverIO.findInPath(platformBin('geckodriver'))
));
return new seleniumWebdriver.Builder()
.forBrowser('firefox')
.setFirefoxOptions(new firefox.Options().headless())
.setFirefoxService(new firefox.ServiceBuilder(
seleniumWebdriverIO.findInPath(platformBin('geckodriver'))
));
};
164 changes: 82 additions & 82 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,102 +7,102 @@ import builderChrome from './builder-chrome.js';
const png = pngjs.PNG.sync;

async function build(builder) {
try {
const selenium = await builder().build();
try {
const selenium = await builder().build();

/* Verify the browser can start */
await selenium.get('data:text/plain,');
/* Verify the browser can start */
await selenium.get('data:text/plain,');

return selenium;
} catch {}
return selenium;
} catch {}
}

export async function grabImage(element) {
const image64 = await element.takeScreenshot();
return png.write(png.read(Buffer.from(image64, 'base64')));
const image64 = await element.takeScreenshot();
return png.write(png.read(Buffer.from(image64, 'base64')));
}

async function getBaseURL(daemon) {
if (typeof daemon === 'string') {
return daemon;
}
if (typeof daemon === 'string') {
return daemon;
}

await daemon.start();
return daemon.baseURL;
await daemon.start();
return daemon.baseURL;
}

async function stopDaemon(daemon) {
if (typeof daemon === 'string') {
return;
}
if (typeof daemon === 'string') {
return;
}

await daemon.stop();
await daemon.stop();
}

export async function testBrowser(t, browser, daemon, pages) {
let builder;
let foundCoverage = false;
const coverageMap = libCoverage.createCoverageMap();

switch (browser) {
case 'chrome':
builder = builderChrome;
break;
case 'firefox':
builder = builderFirefox;
break;
default:
if (typeof browser !== 'function') {
throw new TypeError(`Unknown browser: ${browser}`);
}

builder = browser;
browser = builder.name;
}

const selenium = await build(builder);
if (!selenium) {
t.skip(browser);

return false;
}

const baseURL = await getBaseURL(daemon);
await t.test(browser, {buffered: false}, async t => {
for (const [page, implementation] of Object.entries(pages)) {
t.test(page, {buffered: false}, async t => {
await selenium.get(`${baseURL}${page}`);
await implementation(t, selenium);

/* istanbul ignore else: coverage is always enabled in testing */
if (coverageMap) {
const coverage = await selenium.executeScript(
/* istanbul ignore next: sent to browser */
() => window.__coverage__
);

if (coverage) {
foundCoverage = true;
/* Merge coverage object from the browser running this test. */
coverageMap.merge(coverage);
}
}
});
}
});

await selenium.quit();
await stopDaemon(daemon);

/* istanbul ignore else: coverage is always enabled in testing */
if (foundCoverage) {
/* istanbul ignore else: coverage is always enabled in testing */
if (global.__coverage__) {
coverageMap.merge(global.__coverage__);
}

global.__coverage__ = coverageMap.toJSON();
}

return true;
let builder;
let foundCoverage = false;
const coverageMap = libCoverage.createCoverageMap();

switch (browser) {
case 'chrome':
builder = builderChrome;
break;
case 'firefox':
builder = builderFirefox;
break;
default:
if (typeof browser !== 'function') {
throw new TypeError(`Unknown browser: ${browser}`);
}

builder = browser;
browser = builder.name;
}

const selenium = await build(builder);
if (!selenium) {
t.skip(browser);

return false;
}

const baseURL = await getBaseURL(daemon);
await t.test(browser, {buffered: false}, async t => {
for (const [page, implementation] of Object.entries(pages)) {
t.test(page, {buffered: false}, async t => {
await selenium.get(`${baseURL}${page}`);
await implementation(t, selenium);

/* istanbul ignore else: coverage is always enabled in testing */
if (coverageMap) {
const coverage = await selenium.executeScript(
/* istanbul ignore next: sent to browser */
() => window.__coverage__
);

if (coverage) {
foundCoverage = true;
/* Merge coverage object from the browser running this test. */
coverageMap.merge(coverage);
}
}
});
}
});

await selenium.quit();
await stopDaemon(daemon);

/* istanbul ignore else: coverage is always enabled in testing */
if (foundCoverage) {
/* istanbul ignore else: coverage is always enabled in testing */
if (global.__coverage__) {
coverageMap.merge(global.__coverage__);
}

global.__coverage__ = coverageMap.toJSON();
}

return true;
}
3 changes: 0 additions & 3 deletions nyc.config.cjs

This file was deleted.

1 change: 1 addition & 0 deletions nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default} from '@cfware/nyc';
89 changes: 45 additions & 44 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
{
"name": "@cfware/tap-selenium-manager",
"version": "2.0.0",
"description": "Selenium Manager for tap",
"main": "index.js",
"type": "module",
"scripts": {
"pretest": "cfware-lint .",
"test": "npm run -s tests-only",
"tests-only": "cross-env NODE_OPTIONS='--experimental-loader @istanbuljs/esm-loader-hook' nyc -s node test.js|tap-yaml-summary",
"posttest": "nyc report --check-coverage"
},
"engines": {
"node": ">=16.12.0"
},
"author": "Corey Farrell",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/cfware/tap-selenium-manager.git"
},
"bugs": {
"url": "https://github.com/cfware/tap-selenium-manager/issues"
},
"homepage": "https://github.com/cfware/tap-selenium-manager#readme",
"dependencies": {
"istanbul-lib-coverage": "^3.2.0",
"pngjs": "^6.0.0",
"selenium-webdriver": "^4.4.0"
},
"devDependencies": {
"@babel/core": "^7.18.10",
"@cfware/lint": "^3.0.0",
"@cfware/nyc": "^0.7.1",
"@istanbuljs/esm-loader-hook": "^0.2.0",
"@fastify/static": "^6.5.0",
"babel-plugin-istanbul": "^6.1.1",
"cross-env": "^7.0.3",
"fastify": "^4.4.0",
"fastify-babel": "^3.0.0",
"is-ci": "^3.0.1",
"libtap": "^1.4.0",
"nyc": "^15.1.0",
"tap-yaml-summary": "^0.2.0"
}
"name": "@cfware/tap-selenium-manager",
"version": "2.0.0",
"description": "Selenium Manager for tap",
"main": "index.js",
"exports": "./index.js",
"type": "module",
"scripts": {
"pretest": "cfware-lint .",
"test": "npm run -s tests-only",
"tests-only": "cross-env NODE_OPTIONS='--experimental-loader @istanbuljs/esm-loader-hook' nyc -s node test.js|tap-yaml-summary",
"posttest": "nyc report --check-coverage"
},
"engines": {
"node": ">=18"
},
"author": "Corey Farrell",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/cfware/tap-selenium-manager.git"
},
"bugs": {
"url": "https://github.com/cfware/tap-selenium-manager/issues"
},
"homepage": "https://github.com/cfware/tap-selenium-manager#readme",
"dependencies": {
"istanbul-lib-coverage": "^3",
"pngjs": "^7",
"selenium-webdriver": "^4"
},
"devDependencies": {
"@babel/core": "^7",
"@cfware/lint": "^4",
"@cfware/nyc": "^1",
"@istanbuljs/esm-loader-hook": "^0.2",
"@fastify/static": "^6",
"babel-plugin-istanbul": "^6",
"cross-env": "^7",
"fastify": "^4",
"fastify-babel": "^4",
"is-ci": "^3",
"libtap": "^1",
"nyc": "^15",
"tap-yaml-summary": "^0.2"
}
}
12 changes: 6 additions & 6 deletions tap-snapshots/test.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
'use strict'
exports[`test.js TAP chrome page2.html > must match snapshot 1`] = `
Buffer <
0000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 0000 000a 0000 000a 0806 0000 008d 32cf .PNG........IHDR..............2.
0020: bd00 0000 2449 4441 5478 018d c101 0100 0008 8330 a47f e75b 81ed 0623 9048 2289 ....$IDATx.........0...[...#.H".
0040: 2492 4822 8924 92e8 013d 9c02 12e9 563f 9000 0000 0049 454e 44ae 4260 82 $.H".$...=....V?.....IEND.B\`.
0000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 0000 0007 0000 0007 0806 0000 00c4 5257 .PNG........IHDR..............RW
0020: d300 0000 1f49 4441 5478 017d c101 0100 0008 8020 f3ff e75a 9030 0bcb 4382 0409 .....IDATx.}...........Z.0..C...
0040: 1224 4838 95d6 020c df50 dfdd 0000 0000 4945 4e44 ae42 6082 .$H8.....P......IEND.B\`.
>
`

exports[`test.js TAP chrome page2.html > must match snapshot 2`] = `
Buffer <
0000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 0000 000a 0000 000a 0806 0000 008d 32cf .PNG........IHDR..............2.
0020: bd00 0000 2449 4441 5478 018d c101 0100 0008 8330 a47f e75b 81ed 0623 9048 2289 ....$IDATx.........0...[...#.H".
0040: 2492 4822 8924 92e8 013d 9c02 12e9 563f 9000 0000 0049 454e 44ae 4260 82 $.H".$...=....V?.....IEND.B\`.
0000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 0000 0007 0000 0007 0806 0000 00c4 5257 .PNG........IHDR..............RW
0020: d300 0000 1f49 4441 5478 017d c101 0100 0008 8020 f3ff e75a 9030 0bcb 4382 0409 .....IDATx.}...........Z.0..C...
0040: 1224 4838 95d6 020c df50 dfdd 0000 0000 4945 4e44 ae42 6082 .$H8.....P......IEND.B\`.
>
`

Expand Down
Loading

0 comments on commit c47f159

Please sign in to comment.