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

Coverage failing with version 0.3.6 and up #75

Closed
rox163 opened this issue Nov 7, 2016 · 13 comments
Closed

Coverage failing with version 0.3.6 and up #75

rox163 opened this issue Nov 7, 2016 · 13 comments

Comments

@rox163
Copy link

rox163 commented Nov 7, 2016

I seem to have an issue with v 0.3.6+ of ember-cli-code-coverage.
Running COVERAGE=true ember test kept failing after the last test was run ie when coverage would normally start. Its not repo specific. Doesnt matter what the tests are, this error always shows up at the end

not ok 29 Chrome 54.0 - FrostNavigationService "after each" hook
    ---
        message: >
            Uncaught TypeError: Cannot convert undefined or null to object (http://localhost:7357/5392/tests/index.html?hidepassed:43)
        stack: >
            Error: Uncaught TypeError: Cannot convert undefined or null to object (index.html?hidepassed:43)
                at global.onerror (http://localhost:7357/assets/test-support.js:8732:10)
        Log: |

I have pin pointed this to version 0.3.6 of ember-cli-code-coverage. Up to 0.3.5 everything works great. If you pin to v 0.3.5, coverage is reported properly. Could be related to this PR https://github.com/kategengler/ember-cli-code-coverage/pull/62/files
@rwjblue @rwwagner90

@rwjblue
Copy link
Collaborator

rwjblue commented Nov 7, 2016

Can you tell me if Object.keys(require.entries) causes the same error?

If it does, this is likely the same (or related to the same root cause) as #66.

@rox163
Copy link
Author

rox163 commented Nov 7, 2016

@rwjblue Not sure. What would you like me to do to test that Object.keys line?

@rwjblue
Copy link
Collaborator

rwjblue commented Nov 7, 2016

Run ember test --server, after your tests run in your browser open the console, type Object.keys(require.entries). Is there an error?

@rox163
Copy link
Author

rox163 commented Nov 8, 2016

@rwjblue Yes there is an error.
screen shot 2016-11-08 at 10 07 12 am

@rox163
Copy link
Author

rox163 commented Nov 8, 2016

Any suggestions on how to debug/work around this? As far as I can tell there is no custom require in my project directly but not sure about the dependent addons. We dont use yadda as was mentioned as the culprit in the other issue.
I can point you to a project that has this failure when the coverage version is set to 0.3.6 - https://github.com/ciena-frost/ember-frost-popover/blob/master/package.json

@rox163
Copy link
Author

rox163 commented Nov 11, 2016

Related to #66 as in my case it seems to be a conflict with mocha's require.

@offirgolan
Copy link

offirgolan commented Dec 8, 2016

Bump. I've been running into the same issue:

not ok 219 Chrome 54.0 - Global error: Uncaught TypeError: Cannot convert undefined or null to object at http://localhost:7357/assets/vendor.js, line 73209
    ---
        Log: |
            { type: 'error',
              text: 'Uncaught TypeError: Cannot convert undefined or null to object at http://localhost:7357/assets/vendor.js, line 73209\n' }
    ...
not ok 220 Chrome 54.0 - JSHint | unit/mixins/table-header-test.js: global failure
    ---
        actual: >
            null
        stack: >
            http://localhost:7357/assets/vendor.js:73209
        message: >
            Uncaught TypeError: Cannot convert undefined or null to object
        Log: |
    ...

Running on ember-light-table w/ ember-cli-code-coverage@0.3.8

@RobbieTheWagner
Copy link
Collaborator

@offirgolan are you using something that redefines the global require?

@offirgolan
Copy link

When running what @rwjblue suggested

Run ember test --server, after your tests run in your browser open the console, type Object.keys(require.entries). Is there an error?

I get the same error. require.entries is undefined. I do not believe I have any package that would redefine the global require either...

@a15n
Copy link

a15n commented Jan 31, 2017

I have made a PR to unblock those who are facing this issue. It's a simple require.entries || {} fix.

This doesn't fix any underlying issues with conflicting versions of require but it unblocks those who have conflicting versions.

#97

@job13er
Copy link

job13er commented Apr 25, 2017

In case anyone else is still having an issue with an overwritten require and would like help tracking it down: I added the following to my tests/index.html

(got the console.watch bit from here: http://stackoverflow.com/a/11658693)

<script>
    console = console || {}; // just in case
    console.watch = function(oObj, sProp) {
       sPrivateProp = "$_"+sProp+"_$"; // to minimize the name clash risk
       oObj[sPrivateProp] = oObj[sProp];

       // overwrite with accessor
       Object.defineProperty(oObj, sProp, {
           get: function () {
               return oObj[sPrivateProp];
           },

           set: function (value) {
               //console.log("setting " + sProp + " to " + value);
               debugger; // sets breakpoint
               oObj[sPrivateProp] = value;
           }
       });
    }

    console.watch(window, 'require')
</script>

And then ran my tests in the browser (I used ember s -e test but you could use ember test --server as well). The second debugger that was hit was my culprit.

Still tracking down exactly where the file browserfied-highlight.js comes from, but in our case, it looks like that's the one causing problems.

EDIT: I tracked it down, looks like ember-code-snippet is the addon adding a module that's overriding require.

@job13er
Copy link

job13er commented Apr 25, 2017

I opened ef4/ember-code-snippet#34 to bring it to the attention of the authors of ember-code-snippet. In the meantime, I think I'll use a fork of that project that doesn't use broccoli-browserify

@job13er
Copy link

job13er commented Apr 27, 2017

As mentioned above, this has to do with other addons (in our case brocolli-browserify) overwriting window.require. I don't think it's actually anything this project wants to do anything about. @rox163 You can probably close this guy.

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

6 participants