Skip to content
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

WriteV1Config: fix /tests support #1412

Merged
merged 5 commits into from
Jun 7, 2023

Conversation

22a
Copy link
Member

@22a 22a commented May 8, 2023

Addresses #1387 (development config incorrectly loaded instead of test config when visiting /tests with tests: true, storeConfigInMeta: false)

This PR applies the conditional logic suggested in #1387 (comment)

Screenshot 2023-05-08 at 10 38 45

Example module output with `tests: true`
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _Users_petermeehan_src_embroider_packages_macros_src_addon_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../../../../../Users/petermeehan/src/embroider/packages/macros/src/addon/runtime */ "../../../../../../../../Users/petermeehan/src/embroider/packages/macros/src/addon/runtime.js");

let env;
if ((0,_Users_petermeehan_src_embroider_packages_macros_src_addon_runtime__WEBPACK_IMPORTED_MODULE_0__.isTesting)()) {
 env = {
   "modulePrefix": "with",
   "environment": "test",
   "rootURL": "/",
   "locationType": "none",
   "EmberENV": {
     "FEATURES": {},
     "_APPLICATION_TEMPLATE_WRAPPER": false,
     "_DEFAULT_ASYNC_OBSERVERS": true,
     "_JQUERY_INTEGRATION": false,
     "_TEMPLATE_ONLY_GLIMMER_COMPONENTS": true
   },
   "APP": {
     "rootElement": "#ember-testing",
     "LOG_ACTIVE_GENERATION": false,
     "LOG_VIEW_LOOKUPS": false,
     "autoboot": false,
     "name": "with",
     "version": "0.0.0+ab033a51"
   }
 };
} else {
 env = {
   "modulePrefix": "with",
   "environment": "development",
   "rootURL": "/",
   "locationType": "history",
   "EmberENV": {
     "FEATURES": {},
     "_APPLICATION_TEMPLATE_WRAPPER": false,
     "_DEFAULT_ASYNC_OBSERVERS": true,
     "_JQUERY_INTEGRATION": false,
     "_TEMPLATE_ONLY_GLIMMER_COMPONENTS": true
   },
   "APP": {
     "rootElement": ".non-testing-div",
     "name": "with",
     "version": "0.0.0+ab033a51"
   }
 };
}
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (env);

//# sourceURL=webpack://with/./config/environment.js?
Example module output with `tests: false`
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  "modulePrefix": "with",
  "environment": "development",
  "rootURL": "/",
  "locationType": "history",
  "EmberENV": {
    "FEATURES": {},
    "_APPLICATION_TEMPLATE_WRAPPER": false,
    "_DEFAULT_ASYNC_OBSERVERS": true,
    "_JQUERY_INTEGRATION": false,
    "_TEMPLATE_ONLY_GLIMMER_COMPONENTS": true
  },
  "APP": {
    "rootElement": ".non-testing-div",
    "name": "with",
    "version": "0.0.0+ab033a51"
  }
});

//# sourceURL=webpack://with/./config/environment.js?
Answered questions about the implementation for this.
  • Is changing the type signature of WriteV1Config acceptable? Is there a better way to create an instance of V1Config with env hardcoded to test and pass it in?
    • Discussed in office hours. It's fine.
  • Could this change negatively impact the behaviour of non test builds?
    • Test suite didn't surface anything and my local testing of tests: true and false shows the expected config being loaded
  • Is creating a broccoli plugin with super([inputTree, undefined]) equivalent to super([inputTree])?
  • Is there a good way to add a test for this?

packages/compat/src/v1-config.ts Outdated Show resolved Hide resolved
@22a 22a force-pushed the 22a/writev1config-testing-support branch from 18aa504 to d61234f Compare June 7, 2023 09:08
Copy link
Member

@mansona mansona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 🎉

@mansona mansona merged commit 791c2c3 into embroider-build:main Jun 7, 2023
200 checks passed
@22a 22a deleted the 22a/writev1config-testing-support branch June 7, 2023 12:47
@ef4 ef4 added the bug Something isn't working label Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants