launchcodedev / app-config

Easy Configuration Loader with Strict Validation
https://app-config.dev
Mozilla Public License 2.0
69 stars 11 forks source link

Explore creating a Jest plugin #100

Open joelgallant opened 3 years ago

joelgallant commented 3 years ago

I would rather not point to "just mock the module" when asked how to test app-config.

DetachHead commented 3 years ago

the documentation currently says that

In Node.js, App Config might work without any configuration.

however this doesn't seem to be the case. as far as i can tell, it's impossible to load app-config in jest. calling loadConfig in setupFiles or globalSetup don't seem to work

joelgallant commented 3 years ago

I think something like this is required - https://github.com/facebook/jest/issues/949

Or, following https://github.com/facebook/jest/issues/11038#issuecomment-770182413

In my experience, I've tended to either loadConfig explicitly in beforeEach, or jest.mock'ed.

I'm still quite interested in providing a jest plugin to make this plug-and-play.