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

fingerprinting with 'prepend' option breaks production tests #7157

Open
ctcpip opened this issue Jun 28, 2017 · 1 comment
Open

fingerprinting with 'prepend' option breaks production tests #7157

ctcpip opened this issue Jun 28, 2017 · 1 comment

Comments

@ctcpip
Copy link

ctcpip commented Jun 28, 2017

Using the prepend / fingerprinting described here: https://ember-cli.com/user-guide/#fingerprinting-and-cdn-urls

when prepend option is specified, this breaks ember t --environment=production

looks like it's failing due to the changing of asset URLs in tests/index.html, so they are not found (404)

I guess I know why it's failing - broccoli-asset-rev doesn't care that we're testing, and not creating a production build. Is there a possible workaround?

not ok 1 Chrome 59.0 - Global error: Uncaught ReferenceError: Ember is not defined at http://localhost:7357/4492/tests/index.html?hidepassed, line 39
    ---
        Log: |
            { type: 'error',
              text: 'Uncaught ReferenceError: Ember is not defined at http://localhost:7357/4492/tests/index.html?hidepassed, line 39\n' }
    ...

just tried this with a blank app (ember new) to confirm

repro steps:

  • ember new foo
// ember-cli-build.js

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {
    fingerprint: {
      prepend: '/something/'
    }
  });
  • ember t --environment=production

Output from ember version --verbose && npm --version:

ember-cli: 2.13.2
http_parser: 2.7.0
node: 6.9.1
v8: 5.1.281.84
uv: 1.9.1
zlib: 1.2.8
ares: 1.10.1-DEV
icu: 57.1
modules: 48
openssl: 1.0.2j
os: darwin x64
3.10.8
@ctcpip
Copy link
Author

ctcpip commented Jul 6, 2017

For anyone with the same issue, I am currently using the following workaround

  1. using a combination of the workaround described here: rootURL included in asset path when fingerprint.prepend is present #6212 (comment)
  2. specifying a command line argument that I can read in config/environment.js and ember-cli-build.js as follows:
    • when doing a production build, just build like normal: ember build --environment=production
    • when doing a production test, add a command line argument, which I called test like so: test=false ember build --environment=production (it is necessary to specify the argument before the ember command because ember will discard it otherwise)
    • then we can read this in the two necessary places to conditionally apply the change to rootURL:
// ember-cli-build.js

module.exports = function(defaults) {
  const app = new EmberApp(defaults, {
    fingerprint: {
      prepend: process.env.test === 'false' ? '/something/' : '/'
    }
  });
// config/environment.js

module.exports = function(environment) {

  const ENV = {
    rootURL: '/',
    routerRootURL: '/'
  };

  if (environment === 'production' && process.env.test === 'false') {
    ENV.routerRootURL = '/something/'
  }

  return ENV;
};

It's not pretty but it works. Ideally, there would be an already existing environment flag that we could read - it seems reasonable to expect that we would be able to know whether we ran ember build or ember test without this sort of a workaround.

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

No branches or pull requests

1 participant