GithubHelp home page GithubHelp logo

Comments (4)

NullVoxPopuli avatar NullVoxPopuli commented on July 19, 2024

What's your environment.js look like, as well as which environment variables are set?

from ember-cli.

JackHowa avatar JackHowa commented on July 19, 2024

hmm it's possible that they are running in two different js environments -- config/environment.js in node, the helper function, browser. But I would still expect the config environment to be built by node?


Thanks for the quick response.

config/environment.js looks like essentially:

'use strict';

module.exports = function () {
  let ENV = {
    APP: {
      IS_TEST_ENV: false
    }
  };

  if (process.env.TEST_FLAG) {
    ENV.APP.IS_TEST_ENV = true;
  }

  console.log('output env', ENV.APP);

  //   output env {
  //   IS_TEST_ENV: true,
  // }

  return ENV;
};

Then, when imported into a test helper that runs prior to each qunit test the incoming value is different when logged:

import ENV from 'company/config/environment';

export default function (hooks) {
  hooks.beforeEach(function () {
    console.log(JSON.stringify(ENV.APP), 'env app');
    // {"type":"log","text":"{\"IS_TEST_ENV\":false, }}

    if (ENV.APP.IS_TEST_ENV) {
      // never gets to this
      console.log('DO SOMETHING HERE');
    }
  });
}

I've also tried directly setting the process.env directly on the initial object. I've tried using strings to set values as well. I've also tried setting the value on part of the object that's not within the app key. This works as expected locally but not within circle ci.

Note I can't use the environment incoming value because test, production, and development are already in use and mixed with other variables

from ember-cli.

JackHowa avatar JackHowa commented on July 19, 2024

Problem was a ember buld step that seemed to be the source of truth for the ember test's environment.

from ember-cli.

NullVoxPopuli avatar NullVoxPopuli commented on July 19, 2024

for testing the test environment, you'd probably want import { isTesting, macroCondition } from @embroider/macros`

if (macroCondition(isTesting()) {

}

this way, when isTesting() is false, you don't ship test code to production 🎉

from ember-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.