Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Simulate __DEV__ value in tests #463

Open
simonrobb opened this issue Aug 3, 2018 · 3 comments
Open

Simulate __DEV__ value in tests #463

simonrobb opened this issue Aug 3, 2018 · 3 comments

Comments

@simonrobb
Copy link

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

  1. Write a function which returns __DEV__
  2. Test that function
  3. 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

@KevinGrandon
Copy link
Contributor

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.

@simonrobb
Copy link
Author

I'd be happy to do that, but it doesn't appear to have any effect. I had thought __DEV__ was replaced during compile?

@KevinGrandon
Copy link
Contributor

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.

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

No branches or pull requests

2 participants