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

test: Make axe-core version test more robust #767

Merged
merged 4 commits into from
Aug 7, 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
64 changes: 18 additions & 46 deletions axe_core_test/axe-core-version.test.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,19 @@
const { assert } = require('chai');
const cli = require('../packages/cli/package.json');
const puppeteer = require('../packages/puppeteer/package.json');
const reporterEarl = require('../packages/reporter-earl/package.json');
const webdriverjs = require('../packages/webdriverjs/package.json');

describe('verify axe-core version', () => {
const versioning = /([1-9].[0-9]*)/;

it('cli', () => {
const cliVersion = cli.version;
const cliAxeCoreVersion = cli.dependencies['axe-core'];

const [packageAxeCoreVersion] = cliAxeCoreVersion.match(versioning);
const [axeCoreCliVersion] = cliVersion.match(versioning);
assert.strictEqual(axeCoreCliVersion, packageAxeCoreVersion);
});

it('puppeteer', () => {
const puppeteerVersion = puppeteer.version;
const puppeteerAxeCoreVersion = puppeteer.dependencies['axe-core'];

const [packageAxeCoreVersion] = puppeteerAxeCoreVersion.match(versioning);
const [axeCorePuppeteerVersion] = puppeteerVersion.match(versioning);
assert.strictEqual(axeCorePuppeteerVersion, packageAxeCoreVersion);
});

it('reporter-earl', () => {
const reporterEarlVersion = reporterEarl.version;
const reporterEarlAxeCoreVersion = reporterEarl.devDependencies['axe-core'];

const [packageAxeCoreVersion] =
reporterEarlAxeCoreVersion.match(versioning);
const [axeCoreReporterEarlVersion] = reporterEarlVersion.match(versioning);
assert.strictEqual(axeCoreReporterEarlVersion, packageAxeCoreVersion);
});

it('webdriverjs', () => {
const webdriverjsVersion = webdriverjs.version;
const webdriverjsAxeCoreVersion = webdriverjs.dependencies['axe-core'];

const [packageAxeCoreVersion] = webdriverjsAxeCoreVersion.match(versioning);
const [axeCoreWebdriverjsVersion] = webdriverjsVersion.match(versioning);

assert.strictEqual(axeCoreWebdriverjsVersion, packageAxeCoreVersion);
const assert = require('assert');
const glob = require('glob');
const semver = require('semver');

for (const pkgFile of glob.sync('../packages/*/package.json')) {
const pkg = require(pkgFile);
const axeDependency =
pkg.dependencies?.['axe-core'] || pkg.devDependencies?.['axe-core'];

describe(pkg.name, () => {
it('should have the same semver major/minor as its axe-core dependency', () => {
const axeVersion = semver.parse(semver.coerce(axeDependency));
const pkgVersion = semver.parse(pkg.version);

assert.equal(axeVersion.major, pkgVersion.major);
assert.equal(axeVersion.minor, pkgVersion.minor);
});
});
});
}
Loading