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

Add support for eager via the { eager: true } argument to import.meta.glob in Jest #51

Merged
merged 4 commits into from
Dec 26, 2023

Conversation

vctqs1
Copy link
Contributor

@vctqs1 vctqs1 commented Dec 26, 2023

What:

Addresses #42, and #43 (comment)

Why:
import.meta.globEager is deprecated, use import.meta.glob instead.
But the previous method was use import declarative so it's make Jest failure at import * as glob__glob__
image

How:
Change import statement to require as the implement stuffs in globEager


const modules = import.meta.globEager("./fixtures/**/*")

      ↓ ↓ ↓ ↓ ↓ ↓

const modules = {
  './fixtures/file1.ts': require('./fixtures/file1.ts'),
  './fixtures/file2.ts': require('./fixtures/file2.ts'),
  './fixtures/file3.ts': require('./fixtures/file3.ts')
}

then result is


const __glob__0_0 = require('./fixtures/file1.ts')
const __glob__0_1 = require('./fixtures/file2.ts')
const __glob__0_2 = require('./fixtures/file3.ts')
const modules = {
  './fixtures/file1.ts': __glob__0_0,
  './fixtures/file2.ts': __glob__0_1,
  './fixtures/file3.ts': __glob__0_2
}

Also tested-well in my own repo, and everything is fine
image

Checklist:

  • Documentation updated
  • Tests
  • Ready to be merged
  • Added myself to contributors table

Copy link

codecov bot commented Dec 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (010d7e3) 100.00% compared to head (30b618b) 100.00%.
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #51   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          130       129    -1     
  Branches        49        49           
=========================================
- Hits           130       129    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vctqs1
Copy link
Contributor Author

vctqs1 commented Dec 26, 2023

@mpeyper @JacobMGEvans Hi, I did a fix here, could you two help to review it?

@mpeyper mpeyper merged commit 8abca4b into OpenSourceRaidGuild:main Dec 26, 2023
4 checks passed
Copy link

🎉 This PR is included in version 1.1.2 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version 1.1.1 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants