-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Make axe-core version test more robust (#767)
- Test every package (under `packages/*`) - Use the battle-tested [`semver`](https://www.npmjs.com/package/semver) library rather than a regex
- Loading branch information
1 parent
6be181b
commit 6824caf
Showing
3 changed files
with
887 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.