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

yarn test is failing for me locally #1035

Closed
mstange opened this issue May 23, 2018 · 12 comments
Closed

yarn test is failing for me locally #1035

mstange opened this issue May 23, 2018 · 12 comments

Comments

@mstange
Copy link
Contributor

mstange commented May 23, 2018

I'm using node v10.0.0.

 FAIL  src/test/store/receive-profile.test.js
  ● actions/receive-profile › retrieveProfileFromFile › can load a zipped profile

    expect(received).toBe(expected) // Object.is equality

    Expected value to be:
      "DATA_LOADED"
    Received:
      "FATAL_ERROR"

      671 |         payload: array.buffer,
      672 |       });
    > 673 |       expect(view.phase).toBe('DATA_LOADED');
      674 |       const zipInStore = ZippedProfilesSelectors.getZipFile(getState());
      675 |       if (zipInStore === null) {
      676 |         throw new Error('Expected zipInStore to exist.');

      at Object._callee27$ (src/test/store/receive-profile.test.js:673:26)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
      at step (src/test/store/receive-profile.test.js:59:191)
      at src/test/store/receive-profile.test.js:59:361

I've tracked it down to this check inside getTypeOf in the jszip module:

    if (support.arraybuffer && input instanceof ArrayBuffer) {
        return "arraybuffer";
    }

input instanceof ArrayBuffer is false. But Object.prototype.toString.call(input) === "[object ArrayBuffer]".
Maybe we're picking up two conflicting definitions of ArrayBuffer somehow?

@gregtatum
Copy link
Member

I can confirm it's node v10 failing, and not node v9.

@julienw
Copy link
Contributor

julienw commented May 24, 2018

I don't have any issue on Linux (tried with both v10.0.0 and v10.2.0).

One possibility is that ArrayBuffer in jsdom is different than the native ArrayBuffer. Looking at jsdom's code, it would be surprising, but well. One way to check this is running this in node v10:

const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const { window } = new JSDOM();
console.log(window.ArrayBuffer === ArrayBuffer);

(I can't check myself since I don't have the issue :) )

Unrelated: my search-fu helped me find this random commit: https://github.com/apache/arrow/pull/2049/files#diff-d8a9e815a7bbcefb3c4ef1bec13ffad8R21, which could show an issue around ArrowBuffer in node v10...

@julienw
Copy link
Contributor

julienw commented May 24, 2018

Ah I read in jestjs/jest#4422 that Jest provides custom versions of Buffer types... Could this come from the recent upgrade of Jest?

@julienw
Copy link
Contributor

julienw commented May 24, 2018

I also found jestjs/jest#3186 but this seems an ancient bug.

@julienw
Copy link
Contributor

julienw commented May 24, 2018

Additional note about the latter: we don't use the "node" environment, but the "jsdom" environment.

@mstange
Copy link
Contributor Author

mstange commented May 24, 2018

console.log(window.ArrayBuffer === ArrayBuffer); in the script that you provided prints true on my machine.

I've reduced it down to this printing false inside of the Jest test:

console.log(new Uint8Array().buffer instanceof ArrayBuffer);

I'm going to try to reproduce it in a standalone Jest environment and see whether it's a regression in Jest.

@mstange
Copy link
Contributor Author

mstange commented May 24, 2018

I've filed jestjs/jest#6248 about this and have a workaround.

@mstange
Copy link
Contributor Author

mstange commented May 24, 2018

I tried a few earlier versions of Jest and they all had the same problem, so I don't think it's related to the recent update.

@Zirro
Copy link

Zirro commented May 24, 2018

I'm a maintainer for jsdom, and can confirm that this issue is unrelated to Jest. One of our tests also broke in Node v10 for this reason, but we have yet to discover the cause beyond what you've established here. It presumably comes down to a change in the Node.js vm-module, though.

@mstange
Copy link
Contributor Author

mstange commented May 24, 2018

Thanks for the confirmation! Has an issue been filed in the right place which I could reference?

@Zirro
Copy link

Zirro commented May 24, 2018

Unfortunately I never got to the point of producing a minimal reproduction case due to time constraints (with jsdom being a spare time project).

At the time I was hoping that the issue might get reported by other affected packages, but that doesn't seem to have happened. I guess our use of the vm module is pretty uncommon. I'll see if I can create a proper reproduction case and file an issue in the Node.js-repo soon.

@Zirro
Copy link

Zirro commented May 27, 2018

@mstange If you'd like to update the reference, there's now an issue for this in the Node.js-repo: nodejs/node#20978

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

4 participants