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

import.meta.filename and import.meta.dirname is undefined on Node.js Latest LTS v20.11.0 #5010

Closed
6 tasks done
ghost opened this issue Jan 19, 2024 · 0 comments · Fixed by #5011
Closed
6 tasks done
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@ghost
Copy link

ghost commented Jan 19, 2024

Describe the bug

Node.js implemented API that import.meta.filename and import.meta.dirname on v21.2.0,
and it backported into latest LTS v20.11.0.

Reproduction

vitest: v1.2.1

Repo: https://github.com/d-hajime-san/reference-vitest-import-meta-object

Result

% pnpm test

> reference-vitest-import-meta-object@ test /Users/hostname/repository/reference-vitest-import-meta-object
> vitest run


 RUN  v1.2.1 /Users/hostname/repository/reference-vitest-import-meta-object

 ❯ src/module.test.ts (2)
   ❯ testing import.meta (2)
     × filename
     × dirname

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  src/module.test.ts > testing import.meta > filename
AssertionError: expected undefined to be '/Users/hostname/repository/ref…' // Object.is equality

- Expected: 
"/Users/hostname/repository/reference-vitest-import-meta-object/src/module.test.ts"

+ Received: 
undefined

 ❯ src/module.test.ts:10:34
      8| describe("testing import.meta", () => {
      9|   it("filename", () => {
     10|     expect(import.meta.filename).toBe(__filename);
       |                                  ^
     11|   });
     12|   it("dirname", () => {

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯

 FAIL  src/module.test.ts > testing import.meta > dirname
AssertionError: expected undefined to be '/Users/hostname/repository/ref…' // Object.is equality

- Expected: 
"/Users/hostname/repository/reference-vitest-import-meta-object/src"

+ Received: 
undefined

 ❯ src/module.test.ts:13:33
     11|   });
     12|   it("dirname", () => {
     13|     expect(import.meta.dirname).toBe(__dirname);
       |                                 ^
     14|   });
     15| });

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯

 Test Files  1 failed (1)
      Tests  2 failed (2)
   Start at  17:09:53
   Duration  247ms (transform 49ms, setup 0ms, collect 39ms, tests 5ms, environment 0ms, prepare 85ms)

 ELIFECYCLE  Test failed. See above for more details

System Info

System:
  OS: macOS 13.5.1
  CPU: (8) arm64 Apple M1
  Memory: 588.38 MB / 16.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 20.11.0 - ~/.volta/tools/image/node/20.11.0/bin/node
  npm: 10.2.4 - ~/.volta/tools/image/node/20.11.0/bin/npm
  pnpm: 8.14.0 - ~/.volta/bin/pnpm
Browsers:
  Chrome: 120.0.6099.234
  Chrome Canary: 122.0.6256.6
  Edge: 120.0.2210.144
  Safari: 16.6
  Safari Technology Preview: 17.0
npmPackages:
  vitest: 1.2.1 => 1.2.1

Used Package Manager

pnpm

Validations

@ghost ghost added the pending triage label Jan 19, 2024
@sheremet-va sheremet-va added bug p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Jan 19, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant