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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

import { describe, expect, test } from "@jest/globals";
import { readFileSync } from "node:fs";
import { join, resolve } from "node:path";
import { join, resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";

import { generateLessVariables, generateScssVariables, getParsedVars } from "../cssVariables.mjs";

const FIXTURES_DIR = join(import.meta.dirname, "__fixtures__");
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Comment on lines +12 to +13
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.


const FIXTURES_DIR = join(__dirname, "__fixtures__");
const INPUT_DIR = resolve(FIXTURES_DIR, "input");
const EXPECTED_DIR = resolve(FIXTURES_DIR, "expected");

Expand Down