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: fix node v20 tests #789

Merged
merged 9 commits into from
Aug 22, 2023
Merged

test: fix node v20 tests #789

merged 9 commits into from
Aug 22, 2023

Conversation

AdnoC
Copy link
Contributor

@AdnoC AdnoC commented Aug 9, 2023

No description provided.

@AdnoC AdnoC requested a review from a team as a code owner August 9, 2023 17:25
dbjorge
dbjorge previously requested changes Aug 9, 2023
it('fall back to use `locally` installed axe-core', () => {
const axeSource = utils.getAxeSource();
const axeSource = utils.getAxeSource(undefined, dirname, dirname);
Copy link
Contributor

Choose a reason for hiding this comment

The 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 cwd === dirname in practice. I think it would be preferable to break this out into separate test cases for:

  • it('uses axe.js from the working directory if it exists') (where test setup places axe.js in all 3 locations with different version numbers, to verify which version is actually found)
  • it("falls back to axe-core from the working directory's node_modules if axe.js doesn't exist in the working directory") (where test setup places axe.js in both the dirname and cwd based node_modules paths, but not in cwd, again with different versions to verify which one is found)
  • it("falls back to axe-core from our own package's node_modules if no working-directory based implementation exists") (where test setup only populates the dirname based node_modules path)

'axe.js': mock.load(require.resolve('axe-core'))
}
});
describe.only('mock file', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray .only

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(the axe-core repo uses eslint-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)

Copy link
Member

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.

"version": "4.7.1",
"resolved": "https://registry.npmjs.org/@axe-core/webdriverjs/-/webdriverjs-4.7.1.tgz",
"integrity": "sha512-Cf3gFDKYkMDo1vO9QQ3uIRP/iyiacxbu6YWFl0LqKG3u4AtUeR64xZ5weexr5xAKixu/sDQmcpjLskkgO9QK9w==",
"version": "4.7.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of the type of stray package-lock.json update I mentioned finding concerning in standup earlier - I can live with including it here, just noting it for ease of referencing in retro tomorrow

@AdnoC AdnoC dismissed dbjorge’s stale review August 9, 2023 18:55

Refined tests to check specific axe.js files

@@ -38,24 +38,21 @@
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this file changed?

packages/cli/src/lib/utils.test.ts Outdated Show resolved Hide resolved
packages/cli/src/lib/utils.test.ts Outdated Show resolved Hide resolved
it("falls back to axe-core from the working directory's node_modules if axe.js doesn't exist in the working directory", () => {
const { cliDirname, cwdDirname } = setupTree();
rmSync(join(cwdDirname, 'axe.js'));
const axeSource = utils.getAxeSource(undefined, cliDirname);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be cwdDirname shouldn't it (the working directory)?

Suggested change
const axeSource = utils.getAxeSource(undefined, cliDirname);
const axeSource = utils.getAxeSource(undefined, cwdDirname);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Should be cliDirname because we need a directory with node_modules in it.

AdnoC and others added 2 commits August 22, 2023 10:54
Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com>
Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com>
@AdnoC AdnoC dismissed straker’s stale review August 22, 2023 14:57

Applied suggestions. Answered question

@AdnoC AdnoC merged commit d40ec13 into develop Aug 22, 2023
26 checks passed
@AdnoC AdnoC deleted the ci-fix-node-20 branch August 22, 2023 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants