question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to setup Env vars for running tests

See original GitHub issue

Is this a bug report or a feature request?

🎁 Feature request

Version Info

N/A

How does one specify env vars for running tests? I have npm scripts setup to initialise env vars before running tests like these:

  ...
  "scripts": {
    "test": "better-npm-run test",
  },
  "betterScripts": {
    "test": {
      "command": "jest --coverage",
      "env": {
        "LOG_LEVEL": "silent",
        "NODE_ENV": "test"
      }
    }
  },
  "jest" : { ... }
  ...

With majestic, I cannot set these in the UI since there is no such option and majestic seems to be not using the npm scripts.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Raathigeshcommented, Mar 22, 2019
1reaction
mrchiefcommented, Jan 4, 2018

You could but then I see 2 issues with that:

  • possible duplication of props: you have to declare and maintain same set of vars in 2 places since most projects will have and continue to keep the option of running via CLI (my betterScripts is one such example)

  • takes it further away from being zero-config

Most people have npm test or yarn test configured to run in a certain way. By hooking into that (assuming you have a way of doing that), majestic, “instantly” becomes compatible with virtually every react project in the world. Zero config is the biggest selling point here - I’d suggest to keep it that way .

Eventually, I do see the need of your own separate section but for this specific request, I wouldn’t go that way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing and Environment Variables - Thoughtbot
Learn how to test code using data in environment variables with Climate Control.
Read more >
Ability to Configure Environment Variables for Unit Tests ...
I have an xUnit project which from the IDE I run using the Unit Tests window or the run configuration All tests from...
Read more >
Allow to setup env variables specific to tests. #172 - GitHub
in my app i use Env var to select the configuration. So to select the correct configuration in the test i was looking...
Read more >
Is it possible to set environment variables for exactly one test?
Here is the most common approach: describe('env', function () { var env; // mocking an environment before(function () { env = process.env; process.env...
Read more >
Spring Boot : Integration tests with environment variables
Now that our code works, we want to write an integration test for EmailService. It can be done using GreenMail which creates a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found