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

Fix tests for node@16 error format change #4283

Merged
merged 4 commits into from
Sep 20, 2021
Merged

Conversation

Nargonath
Copy link
Member

Closes #4282.

@Nargonath Nargonath added the test Test or coverage label Sep 12, 2021
@Nargonath Nargonath added this to the 20.2.0 milestone Sep 12, 2021
@Nargonath Nargonath self-assigned this Sep 12, 2021
@Nargonath
Copy link
Member Author

Forgot I had to keep the old message format for node < 16 😅

@devinivy
Copy link
Member

devinivy commented Sep 13, 2021

This update to V8 occurred in node v16.9.0. Could/should we check for node >= v16.9.0 rather than >= v16, even if just to help keep this precisely documented?

Another option is to base the check on the version of V8 process.versions.v8. V8 doesn't follow semver, but the first two numbers reflect the chromium milestone divided by 10 (e.g. chromium M93 <-> v8 9.3), so a comparison like this should work:

// e.g. '9.0.257.24-node.11' -> ['9', '0'] -> '90' -> 90
const toChromiumMilestone = (ver) => parseInt(ver.split('.').slice(0, 2).join(''), 10);

toChromiumMilestone(process.versions.v8) >= 93

@Nargonath
Copy link
Member Author

Yes you're right @devinivy. I'll make the test more precise.

FWIW I prefer to test against the node version than v8. It makes it more easily understandable to others IMO.

Copy link
Contributor

@kanongil kanongil left a comment

Choose a reason for hiding this comment

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

This seems a bit over-engineered. I would just change the test to:

expect(event.error.message).to.include('Cannot read prop');

@Nargonath
Copy link
Member Author

@kanongil The only problem I see with testing that way is that it could shadow a similar error for another field which might not be the problem we want to test here. It's probably unlikely though.

@kanongil
Copy link
Contributor

I know my suggestion is not perfect, but I still think it is a better solution due to the simplicity.

@cjihrig
Copy link
Contributor

cjihrig commented Sep 13, 2021

The only problem I see with testing that way is that it could shadow a similar error for another field

You could add a second assertion for the field name.

@Nargonath
Copy link
Member Author

You could add a second assertion for the field name.

Yes I was just about to say it, you beat me to it.

I know my suggestion is not perfect, but I still think it is a better solution due to the simplicity.

I like your suggestion @kanongil, I'll do it that way and assert on the field name also.

Copy link
Contributor

@kanongil kanongil left a comment

Choose a reason for hiding this comment

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

👍

@Nargonath Nargonath merged commit dcc9ffd into master Sep 20, 2021
@Nargonath Nargonath deleted the fix-tests-node-16 branch September 20, 2021 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Test or coverage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adapt tests to support V8 9.3
4 participants