Skip to content

test: fix node 6 tests by pinning to sax 1.4.1 in old node versions#4925

Merged
dbjorge merged 1 commit intodevelopfrom
fix-node-6-tests
Nov 3, 2025
Merged

test: fix node 6 tests by pinning to sax 1.4.1 in old node versions#4925
dbjorge merged 1 commit intodevelopfrom
fix-node-6-tests

Conversation

@dbjorge
Copy link
Copy Markdown
Contributor

@dbjorge dbjorge commented Nov 3, 2025

Copilot AI review requested due to automatic review settings November 3, 2025 20:18
@dbjorge dbjorge requested a review from a team as a code owner November 3, 2025 20:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the dependency installation logic to support installing multiple dependencies per Node version, with a focus on adding explicit sax dependency for older Node versions (4 and 6).

  • Renamed nodeToJsdomMatrix to nodeToDeps and changed structure from version string to array of dependency specifications
  • Modified installation logic to loop through multiple dependencies instead of a single jsdom package
  • Consolidated npm spawn call to install all dependencies in a single command

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


var deps = nodeToDeps[majorNodeVersion] || ['jsdom@latest'];
var nodeInstallArgs = ['install', '--no-save'];
for (var dep of deps) {
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The for...of loop syntax is not compatible with ES5, which this file explicitly targets (see comment on line 1-2 stating 'this file is purposefully written...in es5 syntax in order to be compatible with node 4+'). Use a traditional for loop instead: for (var i = 0; i < deps.length; i++).

Suggested change
for (var dep of deps) {
for (var i = 0; i < deps.length; i++) {
var dep = deps[i];

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems legit - nice catch, Copilot! 🤖

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The comment is a bit misleading; it's true that we need the script to be node-4-compatible, but we don't actually need "ES5" compat, node 4 supports for-of

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's what I figured

14: '21.1.2',
16: '22.1.0',
18: '26.1.0'
var nodeToDeps = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clever!

Copy link
Copy Markdown
Member

@stephenmathieson stephenmathieson left a comment

Choose a reason for hiding this comment

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

LGTM assuming Copilot's for loop concern is moot

@dbjorge dbjorge merged commit 671de01 into develop Nov 3, 2025
29 checks passed
@dbjorge dbjorge deleted the fix-node-6-tests branch November 3, 2025 20:28
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.

3 participants