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 node-build-scripts-test failing in validate #6934

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

ggdouglas
Copy link
Contributor

@ggdouglas ggdouglas commented Aug 5, 2024

Fixes #6926

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

This PR resolves failing tests encountered while running the introductory yarn validate command (from the README).

tl;dr The test uses a variable that should exist in the version of Node we're running but doesn't exist during the build.

Before After
before after

The "fix" involved here replaces the use of import.meta.dirname in cssVariables.test.ts with an alternative method of accessing the current folder path. This method was considered one of the ways to expose __dirname in an ES module prior to it being added in v20.11.0 (see this article for more context).

For some reason, import.meta.dirname is undefined when running the test scripts. According to the docs it should be there. The typings assume that it is, but in reality only import.meta.url is defined.

It might be worth investigating why the build system doesn't expose these variables at runtime when they're supposed to exist. Perhaps there is something deeper in webpack config that needs addressing.

I did not encounter the scrollbar test flake described in #6926, so those tests are not addressed here.

@changelog-app
Copy link

changelog-app bot commented Aug 5, 2024

Generate changelog in packages/node-build-scripts/changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Fix node-build-scripts-test failing in validate

Check the box to generate changelog(s)

  • Generate changelog entry

Comment on lines +12 to +13
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does __dirname need to be defined? Curious if this works without it?

https://nodejs.org/docs/latest/api/modules.html#__dirname

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this was the first thing I tried but it sadly does not seem to work:

Screenshot 2024-08-05 at 17 15 05@2x

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see. It looks like that's because we're already opting into Jest's ESM support based on the node:80071 warning. It makes sense that __dirname (a CommonJS feature) isn't available given that. Thanks for trying.

Copy link
Contributor

@gluxon gluxon left a comment

Choose a reason for hiding this comment

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

Thank you @ggdouglas!

@ggdouglas ggdouglas merged commit 02174c9 into develop Aug 5, 2024
12 of 14 checks passed
@ggdouglas ggdouglas deleted the gdouglas/fix-node-build-scripts-test branch August 5, 2024 21:24
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.

Some tests failing when running yarn verify
3 participants