Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite updates #281

Merged
merged 22 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ on:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
node-version: ['12.x', '14.x', '16.x']
node-version: ['16.x', '18.x', '20.x']

steps:
- name: Checkout
Expand All @@ -29,16 +30,13 @@ jobs:
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: npm7
if: matrix.node-version != '16.x'
run: npm i -g npm@7
- name: Install
run: npm ci
- name: Lint
if: matrix.node-version == '16.x'
if: matrix.node-version == '18.x'
run: npm run lint
- name: Prettier
if: matrix.node-version == '16.x'
if: matrix.node-version == '18.x'
run: npm run prettier:check
- name: Test
run: npm test
Expand All @@ -50,7 +48,7 @@ jobs:
--shm-size="2g" \
--name selenium_server \
-v ${PWD}:${PWD} \
selenium/standalone-firefox:4.0.0-rc-2-prerelease-20210916
selenium/standalone-firefox:4.16.1-20231219
- name: Integration
run: npm run test:integration
- name: Stop Selenium Server
Expand Down
2 changes: 1 addition & 1 deletion cli/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cli
# Mochify CLI

## Usage

Expand Down
7 changes: 5 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"main": "index.js",
"scripts": {
"test": "echo \"No unit tests yet\"",
"test:integration": "mocha --timeout 10000 '**/*.integration.js'",
"test:integration": "mocha --timeout 10000 -R spec '**/*.integration.js'",
"preversion": "npm run test && npm run test:integration",
"postversion": "npm publish"
},
Expand All @@ -31,9 +31,12 @@
"yargs": "^16.2.0"
},
"devDependencies": {
"@sinonjs/referee-sinon": "^10.1.0",
"@sinonjs/referee-sinon": "^11.0.0",
"execa": "^5.1.1"
},
"engines": {
"node": ">=16"
},
"files": [
"**/*.js",
"!**/*.test.js",
Expand Down
9 changes: 6 additions & 3 deletions cli/test/config.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const execa = require('execa');
describe('config', () => {
it('mochify.config.js', async () => {
const result = await execa('../../index.js', ['passes.js'], {
cwd: path.join(__dirname, 'fixture')
cwd: path.join(__dirname, 'fixture'),
stderr: process.stderr
});

const json = JSON.parse(result.stdout);
Expand All @@ -20,7 +21,8 @@ describe('config', () => {
'../../index.js',
['--config', 'custom.config.yaml', 'passes.js'],
{
cwd: path.join(__dirname, 'fixture')
cwd: path.join(__dirname, 'fixture'),
stderr: process.stderr
}
);

Expand All @@ -32,7 +34,8 @@ describe('config', () => {
'../../index.js',
['--reporter', 'tap', '--driver', 'jsdom', 'passes.js'],
{
cwd: path.join(__dirname, 'fixture')
cwd: path.join(__dirname, 'fixture'),
stderr: process.stderr
}
);

Expand Down
3 changes: 2 additions & 1 deletion cli/test/jsdom.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ describe('jsdom', () => {
'../../index.js',
[file, '--driver', 'jsdom', ...extra_args],
{
cwd: path.join(__dirname, 'fixture')
cwd: path.join(__dirname, 'fixture'),
stderr: process.stderr
}
);
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion cli/test/playwright.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ describe('playwright', () => {
...extra_args
],
{
cwd: path.join(__dirname, 'fixture')
cwd: path.join(__dirname, 'fixture'),
stderr: process.stderr
}
);
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion cli/test/puppeteer.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ describe('puppeteer', () => {
'../../index.js',
[file, '--driver', 'puppeteer', ...extra_args],
{
cwd: path.join(__dirname, 'fixture')
cwd: path.join(__dirname, 'fixture'),
stderr: process.stderr
}
);
} catch (error) {
Expand Down
26 changes: 18 additions & 8 deletions cli/test/webdriver.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ describe('webdriver', () => {
'../../index.js',
[file, '--driver', 'webdriver', ...extra_args],
{
cwd: path.join(__dirname, 'fixture')
cwd: path.join(__dirname, 'fixture'),
stderr: process.stderr
}
);
} catch (error) {
Expand All @@ -32,7 +33,7 @@ describe('webdriver', () => {
const result = await run('passes.js');

assert.isFalse(result.failed);
const json = JSON.parse(result.stdout);
const json = getResultStdoutAsJson(result);
assert.equals(json.tests.length, 1);
assert.equals(json.tests[0].fullTitle, 'test passes');
});
Expand All @@ -53,7 +54,7 @@ describe('webdriver', () => {
}

assert.isFalse(result.failed);
const json = JSON.parse(result.stdout);
const json = getResultStdoutAsJson(result);
assert.equals(json.tests.length, 1);
assert.equals(json.tests[0].fullTitle, 'test passes');
});
Expand All @@ -62,7 +63,7 @@ describe('webdriver', () => {
const result = await run('fails.js');

assert.isTrue(result.failed);
const json = JSON.parse(result.stdout);
const json = getResultStdoutAsJson(result);
assert.equals(json.tests.length, 1);
assert.equals(json.tests[0].fullTitle, 'test fails');
});
Expand All @@ -71,7 +72,7 @@ describe('webdriver', () => {
const result = await run('client-leak.js');

assert.isFalse(result.failed);
const json = JSON.parse(result.stdout);
const json = getResultStdoutAsJson(result);
assert.equals(json.tests.length, 1);
assert.equals(
json.tests[0].fullTitle,
Expand All @@ -83,11 +84,12 @@ describe('webdriver', () => {
function pingSelenium() {
return new Promise((resolve, reject) => {
http
.get('http://localhost:4444/wd/hub/status', ({ statusCode }) => {
if (statusCode !== 200) {
.get('http://localhost:4444/wd/hub/status', (res) => {
res.on('data', () => {}); // consume request body
if (res.statusCode !== 200) {
reject(
new Error(
`Received unexpected ${statusCode} response from "/wd/hub/status"`
`Received unexpected ${res.statusCode} response from "/wd/hub/status"`
)
);
return;
Expand All @@ -99,3 +101,11 @@ function pingSelenium() {
});
});
}

function getResultStdoutAsJson(result) {
// At some point between v8.10 and v8.27 WebDriver started to log one line
// with level INFO, even though the log level is set to "warn".
//
// 2023-12-22T14:01:31.855Z INFO @wdio/utils: Connecting to existing driver …
return JSON.parse(result.stdout.substring(result.stdout.indexOf('{')));
}
2 changes: 1 addition & 1 deletion driver-jsdom/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# driver-jsdom
# Mochify driver for JSDOM

Run tests in [JSDOM][web].

Expand Down
4 changes: 2 additions & 2 deletions driver-jsdom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"author": "Maximilian Antoni <[email protected]> (http://maxantoni.de)",
"license": "MIT",
"dependencies": {
"jsdom": "^16.6.0"
"jsdom": "^23.0.1"
},
"peerDependencies": {
"@mochify/mochify": "^0.1.0 || ^0.2.0"
},
"engines": {
"node": ">=12.0.0"
"node": ">=16"
},
"files": [
"**/*.js",
Expand Down
2 changes: 1 addition & 1 deletion driver-playwright/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# driver-playwright
# Mochify driver for Playwright

Run tests in [Playwright][web].

Expand Down
4 changes: 2 additions & 2 deletions driver-playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"author": "Maximilian Antoni <[email protected]> (http://maxantoni.de)",
"license": "MIT",
"dependencies": {
"playwright": "^1.12.3"
"playwright": "^1.40.1"
},
"peerDependencies": {
"@mochify/mochify": "^0.1.0 || ^0.2.0"
Expand All @@ -33,6 +33,6 @@
"!.*"
],
"engines": {
"node": ">=12.0.0"
"node": ">=16"
}
}
2 changes: 1 addition & 1 deletion driver-puppeteer/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# driver-puppeteer
# Mochify driver for Puppeteer

Run tests in [Puppeteer][web].

Expand Down
1 change: 1 addition & 0 deletions driver-puppeteer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async function mochifyDriver(options = {}) {
];

const browser = await driver.launch({
headless: 'new',
ignoreHTTPSErrors: true,
// Workaround for https://github.com/puppeteer/puppeteer/issues/6957
executablePath: process.env.PUPPETEER_EXECUTABLE_PATH,
Expand Down
4 changes: 2 additions & 2 deletions driver-puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"author": "Maximilian Antoni <[email protected]> (http://maxantoni.de)",
"license": "MIT",
"dependencies": {
"puppeteer": "^10.0.0"
"puppeteer": "^21.6.1"
},
"peerDependencies": {
"@mochify/mochify": "^0.1.0 || ^0.2.0"
},
"engines": {
"node": ">=12.0.0"
"node": ">=16"
},
"files": [
"index.html",
Expand Down
7 changes: 4 additions & 3 deletions driver-webdriver/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Mochify Driver for WebDriver
# Mochify driver for WebDriver

## Local Selenium

Installing selenium server on Mac OS:

```bash
brew install selenium-server-standalone
brew install selenium-server
brew install geckodriver
```

Starting the server:

```bash
selenium-server -port 4444
selenium-server standalone --port 4444
```

Configuration for local Selenium:
Expand Down
2 changes: 1 addition & 1 deletion driver-webdriver/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const WebDriver = require('webdriver').default;
const { WebDriver } = require('webdriver');

exports.mochifyDriver = mochifyDriver;

Expand Down
5 changes: 4 additions & 1 deletion driver-webdriver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
"author": "Maximilian Antoni <[email protected]> (http://maxantoni.de)",
"license": "MIT",
"dependencies": {
"webdriver": "^7.7.4"
"webdriver": "^8.27.0"
},
"peerDependencies": {
"@mochify/mochify": "^0.1.0 || ^0.2.0"
},
"engines": {
"node": ">=16"
},
"files": [
"index.html",
"**/*.js",
Expand Down
1 change: 1 addition & 0 deletions mochify/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function requestHandler(base_path, { scripts = [], modules = [] }) {
res.end(`
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
${scripts.map((script) => `<script>${script}</script>`).join('')}
${modules.map((mod) => `<script type="module" src="${mod}"></script>`).join('')}
Expand Down
10 changes: 5 additions & 5 deletions mochify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"test": "mocha '**/*.test.js'",
"test:integration": "mocha --timeout 10000 '**/*.integration.js'",
"test:integration": "mocha --timeout 10000 -R spec '**/*.integration.js'",
"watch": "npm test -- --watch",
"preversion": "npm test && npm run test:integration",
"postversion": "npm publish"
Expand All @@ -17,9 +17,9 @@
"testing"
],
"author": "Maximilian Antoni <[email protected]> (http://maxantoni.de)",
"license": "ISC",
"license": "MIT",
"engines": {
"node": ">=12"
"node": ">=16"
},
"mocha": {
"reporter": "dot",
Expand All @@ -33,12 +33,12 @@
"execa": "^5.1.1",
"glob": "^7.1.7",
"mime": "^2.5.2",
"mocha": "^9.0.0",
"mocha": "^10.2.0",
"source-map": "^0.5.7",
"string-argv": "^0.3.1"
},
"devDependencies": {
"@sinonjs/referee-sinon": "^10.1.0",
"@sinonjs/referee-sinon": "^11.0.0",
"proxyquire": "^2.1.3"
},
"files": [
Expand Down
Loading
Loading