fusion-cli
fusion-cli copied to clipboard
Simulate `__DEV__` value in tests
Type of issue
Feature request
Description
I'd like to test a behavior that varies with the value of __DEV__
. There isn't a way to simulate this value in tests.
Current behavior
__DEV__
is true
while developing tests locally. I'm not sure what the value would be on a CI server.
Expected behavior
Ideally the __DEV__
value should be configurable on a per-test basis.
Steps to reproduce
- Write a function which returns
__DEV__
- Test that function
- Profit?
Your environment
-
fusion-cli version: 1.8.5
-
Node.js version (
node --version
): v8.11.3 -
npm version (
npm --version
): 5.6.0 -
Operating System: OSX
So one janky way of doing this before might be to mock with global.__DEV__ = false;
. It's probably not what we want to suggest long term, but might be enough to get you unblocked. I believe we're going to re-evaluate environment variable usage soon, and this is possibly something we can make better as well when we do that.
I'd be happy to do that, but it doesn't appear to have any effect. I had thought __DEV__
was replaced during compile?
I'd be happy to do that, but it doesn't appear to have any effect. I had thought DEV was replaced during compile?
I think it depends on when you set it. If you set it before the code executes, it should work. We use a babel transformer for jest tests, so the build is a little bit different. Happy to sit with you next week to see if we can figure out a quick workaround if you want.