Skip to content

fix(tools): update failing tests on main - #51980

Merged
raisedadead merged 7 commits into
freeCodeCamp:mainfrom
spellware:fix/jest
Oct 15, 2023
Merged

raisedadead merged 7 commits into
freeCodeCamp:mainfrom
spellware:fix/jest

Conversation

@naomi-lgbt

Copy link
Copy Markdown
Member

Checklist:

Tracing this issue back, discovered that some optimisation changes to the fs.readFileSync broke the ability for mock-fs to mock the file system correctly.

The workaround for this, until the upstream issue is fixed, is to not pass the utf-8 argument, but to instead call toString('utf-8') on the returned Buffer.

This also meant that matter.read() was unusable, as it appears to default to passing the parameter. Instead, we have to read the file separately, and pass the contents to matter() directly.

image

Tools tests are now all passing locally for me on my node 20 instance.

@naomi-lgbt
naomi-lgbt requested review from a team and raisedadead October 15, 2023 06:31
@github-actions github-actions Bot added the scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. label Oct 15, 2023
@ghost

ghost commented Oct 15, 2023 •

Copy link
Copy Markdown

👀 Review this PR in a CodeSee Review Map

View the CodeSee Map of this change

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@naomi-lgbt naomi-lgbt changed the title fix(tools): update tests for challenge helpers fix(tools): update failing tests on main Oct 15, 2023
@gikf

gikf commented Oct 15, 2023 •

Copy link
Copy Markdown
Member

These work on node 20.7.0. 20.8.0 appears to make more changes that mock-fs doesn't like.

@huyenltnguyen huyenltnguyen left a comment

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.

LGTM 👍

I think we should create an issue to track the removal of the workaround though.

@huyenltnguyen huyenltnguyen mentioned this pull request Oct 15, 2023
4 tasks done
@huyenltnguyen

Copy link
Copy Markdown
Member

I think we will need to pin Node on 20.7.0 as well. I tested the PR locally and confirmed that the tests pass on v20.7 but some fail on v20.8, as @gikf pointed out.

@naomi-lgbt

Copy link
Copy Markdown
Member Author
image

Okay I threw out the mock-fs and just wrote to the file system (and cleaned it up after) directly. That gets these passing locally on Node 20.8.1 finally.

@huyenltnguyen huyenltnguyen left a comment

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.

Could we revert the .toString('utf-8') workaround then, or do we still need it?

@raisedadead
raisedadead merged commit dbcc2af into freeCodeCamp:main Oct 15, 2023
@naomi-lgbt
naomi-lgbt deleted the fix/jest branch October 15, 2023 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants