-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment is "development" instead of "test" during tests #32
Comments
Hey @viniciussbs - Quick question: How are you running the tests for you application? |
Hi! |
Ok great. In trying to track this one down I noticed that if you run I'm waiting to hear back on if we can have the |
Ok quick follow up! Because you're running In order to get this fixed I believe it will require a change to FastBoot. We need a way to tell FastBoot to run with a different environment configuration from what it was built with. My guess is this will require a change to FastBoot itself. I'm going to close this discussion because I'm not sure there's anything this library can do right now to move this forward. There's an issue over here in FastBoot to track this: ember-fastboot/fastboot#218 |
Nice! I usually run Thank you! |
Spent some time trying to track this down and crawled through the fastboot source yesterday, and figured out a way to make this work right now in the fastboot-testing.js //config/fastboot-testing.js
let config = require('./environment');
module.exports = {
resilient: false,
sandboxGlobals: {},
setupFastboot: fastbootInstance => {
let oldConfig;
if (process.env.APP_CONFIG) {
oldConfig = process.env.APP_CONFIG;
}
process.env.APP_CONFIG = JSON.stringify(config('test'));
fastbootInstance.reload()
if (oldConfig) {
process.env.APP_CONFIG = oldConfig;
}
else {
delete process.env.APP_CONFIG
}
}
}; Basically what's happening is when the ember app gets built all the current environment config gets stuffed into the package.json file under "AppConfig", which is where it gets read out of when the app gets built in Fastboot. Relevant lines: So all we need to do from this addon is set the But this should get @viniciussbs going until a real fix can be put in. And good news: probably no need to modify fastboot? What do you think, @ryanto? |
Oh awesome nice find!
|
With more people using that mockServer to do full blown acceptance testing with network requests, I'd imagine more people would be perplexed by that issue due to the common pattern of setting env vars for network URLs in the application environment config. The way this bug presented itself to me was the fastboot app loading data from development URLs instead of test data.
|
Ok cool! I'm on board unless anyone has any objections. I guess we could move the Also, once that app is booted should we reset |
Well I spoke too soon and ran into a snag with this hack approach that maybe our fix can overcome? This So I guess we do need to be really careful about that env var in making sure to reset it after it's done what we need it to |
Updated my code snippet above (#32 (comment)) to account for the above problem and it's working as it should now. Still not sure why that hook loads in dev mode though |
Great! If we're going to bring this into Fastboot testing does it make sense to move the env logic into this function (https://github.com/embermap/ember-cli-fastboot-testing/blob/master/lib/helpers.js#L73) so that we don't need to call reload? Any downsides? |
That seems good, I think we might need to do it again before the |
Yup nice catch! |
Hi! I don't know if this is a bug here or maybe on FastBoot - or maybe I am missing something. But this code is evaluating
"development"
instead of"test"
:This happens only in FastBoot tests. In acceptance tests it evaluates
"test"
.The text was updated successfully, but these errors were encountered: