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

Ember Upgrade: global is not defined #655

Open
bmoellers opened this issue Apr 2, 2021 · 0 comments
Open

Ember Upgrade: global is not defined #655

bmoellers opened this issue Apr 2, 2021 · 0 comments

Comments

@bmoellers
Copy link

So awhile ago I tried to upgrade from 2.16 to 3.4 and got unit tests basically running but not working. However being an active application, we had to abandon the upgrade and get "real" work done (yes I quoted real because to me as a developer getting up to the latest version is as important as new features but I lost that battle). So now after a security review they are asking us to upgrade from 2.16 to 3.25 of Ember when we can.

So the branch for 3.4 runs the test. 3.25.1 was not running the tests suites. I think I figured that out as I had both ember-mocha and mocha somehow installed. Once I removed mocha from package.json I see at least two tests running however I keep getting an error.

ReferenceError: global is not defined

So originally this was triggered because we were trying to load fixtures data and we had a system that could select a user and return different data. Example: US user -> returns data for the US and German user -> returns data for Germany. We put the users on the global because it was shared with the sandbox that we use for local testing since this app is meant to be used in an iFrame for our other applications. I fixed that by just removing the global instance and the users in the sandbox and the fixtures which is not ideal but I will fix that up later.

However we use sinon sandbox for our tests and we have a simple helper that sets that up for us:

import sinon from 'sinon';
import { beforeEach, afterEach } from 'mocha';

beforeEach(function () {
  global.sandbox = sinon.sandbox.create(); // eslint-disable-line no-undef
});

afterEach(function () {
  if (global.sandbox) { // eslint-disable-line no-undef
    global.sandbox.restore(); // eslint-disable-line no-undef
    delete global.sandbox; // eslint-disable-line no-undef
  }
});

And this is resulting in this error. I am using ember-auto-import and I found some issues on line that said they added a global: true to the node to fix it in the application so I did that:

    autoImport: {
      webpack: {
        node: {
          fs: 'empty',
          global: true,
        },
      },
    },

I still get the error. Any ideas?

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