-
Notifications
You must be signed in to change notification settings - Fork 68
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: fix node v20 tests #789
Changes from 2 commits
170db6b
5169f3b
a54c006
8569edd
c649639
89c8b70
aa42f35
d74a895
1d7ef6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import 'mocha'; | ||
import { assert } from 'chai'; | ||
import mock = require('mock-fs'); | ||
import tempy from 'tempy'; | ||
import { join } from 'path'; | ||
import { mkdirSync, writeFileSync } from 'fs'; | ||
import { dependencies } from '../../package.json'; | ||
import * as utils from './utils'; | ||
|
||
|
@@ -73,25 +75,33 @@ describe('utils', () => { | |
}); | ||
|
||
describe('getAxeSource', () => { | ||
describe('mock file', () => { | ||
beforeEach(() => { | ||
mock({ | ||
'/node_modules/axe-core': {}, | ||
'../node_modules/axe-core': { | ||
'axe.js': mock.load(require.resolve('axe-core')) | ||
} | ||
}); | ||
describe.only('mock file', () => { | ||
let dirname = '<NOT A FILE>'; | ||
before(() => { | ||
const axeVersionCheck = dependencies['axe-core'].replace('^', ''); | ||
const tempDir = tempy.directory(); | ||
mkdirSync(join(tempDir, 'node_modules')); | ||
mkdirSync(join(tempDir, 'node_modules', 'axe-core')); | ||
writeFileSync( | ||
join(tempDir, 'node_modules', 'axe-core', 'axe.js'), | ||
`"${axeVersionCheck}"` | ||
); | ||
|
||
mkdirSync(join(tempDir, 'packages')); | ||
mkdirSync(join(tempDir, 'packages', 'cli')); | ||
mkdirSync(join(tempDir, 'packages', 'cli', 'node_modules')); | ||
mkdirSync(join(tempDir, 'packages', 'cli', 'node_modules', 'axe-core')); | ||
dirname = join(tempDir, 'packages', 'cli', 'lib'); | ||
mkdirSync(dirname); | ||
}); | ||
|
||
afterEach(() => { | ||
mock.restore(); | ||
}); | ||
it('fall back to use `locally` installed axe-core', () => { | ||
const axeSource = utils.getAxeSource(); | ||
const axeSource = utils.getAxeSource(undefined, dirname, dirname); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this update, I feel a bit confused about what this test is trying to actually verify - I'm not sure there's any meaningful real case where
|
||
const axeVersionCheck = dependencies['axe-core'].replace('^', ''); | ||
assert.include(axeSource, axeVersionCheck); | ||
}); | ||
}); | ||
|
||
it('given no axe source use local source', () => { | ||
const axeSource = utils.getAxeSource(); | ||
assert.isNotNull(axeSource); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray
.only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(the
axe-core
repo useseslint-plugin-mocha-no-only
to prevent this class of mistake from being merged accidentally, maybe would be good for a separate PR to add that in this repo as well)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use https://www.npmjs.com/package/eslint-plugin-mocha elsewhere, which offers many other useful rules.