Skip to content

Commit

Permalink
chore(NPM): updated Electron (v33) and Puppeteer, also Jest unit test…
Browse files Browse the repository at this point in the history
…ing environment.
  • Loading branch information
danielweck committed Nov 1, 2024
1 parent 847f44b commit 70a093d
Show file tree
Hide file tree
Showing 9 changed files with 875 additions and 927 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"strip-ansi": "^6.0.0"
},
"resolutions": {
"electron": "^32.1.1"
"electron": "^33.0.2"
},
"scripts": {
"axe-dev": "cpy \"../axe-core_DAISY/axe.js\" \"node_modules/@daisy/axe-core-for-ace/\" && cpy \"../axe-core_DAISY/axe.min.js\" \"node_modules/@daisy/axe-core-for-ace/\" && cpy \"../axe-core_DAISY/axe.d.ts\" \"node_modules/@daisy/axe-core-for-ace/\" && cpy \"../axe-core_DAISY/locales/*.*\" \"node_modules/@daisy/axe-core-for-ace/locales/\" && cpy \"../axe-core_DAISY/package.json\" \"node_modules/@daisy/axe-core-for-ace/\"",
Expand Down
2 changes: 1 addition & 1 deletion packages/ace-axe-runner-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"uuid": "^8.3.2"
},
"devDependencies": {
"electron": "^32.1.1"
"electron": "^33.0.2"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/ace-axe-runner-puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"main": "lib/index.js",
"dependencies": {
"@daisy/puppeteer-utils": "1.3.3-alpha.3",
"puppeteer": "^23.4.0"
"puppeteer": "^23.6.1"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 2 additions & 0 deletions packages/ace-core/src/scripts/ace-extraction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

'use strict';

// yarn test -t="packages/ace-core/src/scripts/ace-extraction.test.js"

const $ = require('@daisy/jest-puppeteer');

beforeAll(async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@daisy/ace-cli": "1.3.3-alpha.3",
"@daisy/ace-core": "1.3.3-alpha.3",
"@daisy/ace-http": "1.3.3-alpha.3",
"electron": "^32.1.1"
"electron": "^33.0.2"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-env-puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"license": "MIT",
"main": "lib/index.js",
"dependencies": {
"jest-environment-node": "^26.6.2",
"puppeteer": "^23.4.0"
"jest-environment-node": "^29.7.0",
"puppeteer": "^23.6.1"
},
"publishConfig": {
"access": "public"
Expand Down
49 changes: 39 additions & 10 deletions packages/jest-env-puppeteer/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,61 @@

'use strict';

const NodeEnvironment = require('jest-environment-node');
// yarn test -t="packages/ace-core/src/scripts/ace-extraction.test.js"

const NodeEnvironment = require('jest-environment-node').TestEnvironment;
const puppeteer = require('puppeteer');
const os = require('os');

class HeadlessChromeEnvironment extends NodeEnvironment {
constructor(config, context) {
super(config, context);
// console.log(config.globalConfig);
// console.log(config.projectConfig);
// this.testPath = context.testPath;
// this.docblockPragmas = context.docblockPragmas;
}

async setup() {
// await super.setup();
// await someSetupTasks(this.testPath);
// this.global.someGlobalObject = createGlobalObject();
// // Will trigger if docblock contains @my-custom-pragma my-pragma-value
// if (this.docblockPragmas['my-custom-pragma'] === 'my-pragma-value') {
// // ...
// }

setup() {
const args = [];
// if (os.platform() !== 'win32' && os.platform() !== 'darwin') {
// args.push('--no-sandbox')
// }
args.push('--no-sandbox');
args.push('--disable-setuid-sandbox');
return super.setup().then(() =>
puppeteer.launch({ args, headless: true }).then((browser) => {
this.global.browser = browser;
}));

await super.setup();

await puppeteer.launch({ args, headless: true }).then((browser) => {
this.global.browser = browser;
});
}

teardown() {
return this.global.browser.close().then(() => super.teardown());
async teardown() {
// this.global.someGlobalObject = destroyGlobalObject();
// await someTeardownTasks();
// await super.teardown();

this.global.browser.close().then(async () => await super.teardown());
}

runScript(script) {
return super.runScript(script);
getVmContext() {
return super.getVmContext();
}

// async handleTestEvent(event, state) {
// if (event.name === 'test_start') {
// // ...
// }
// }
}

module.exports = HeadlessChromeEnvironment;
2 changes: 1 addition & 1 deletion packages/jest-puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"main": "lib/index.js",
"dependencies": {
"@daisy/puppeteer-utils": "1.3.3-alpha.3",
"jest-mock": "^26.6.2"
"jest-mock": "^29.7.0"
},
"publishConfig": {
"access": "public"
Expand Down
1,737 changes: 827 additions & 910 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 70a093d

Please sign in to comment.