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

Assertion `Buffer::HasInstance(args[4])' failed #2042

Closed
VinSpee opened this issue Feb 16, 2018 · 5 comments
Closed

Assertion `Buffer::HasInstance(args[4])' failed #2042

VinSpee opened this issue Feb 16, 2018 · 5 comments

Comments

@VinSpee
Copy link

VinSpee commented Feb 16, 2018

  • Puppeteer version: 1.0.0-next.1518730236759
  • Platform / OS version: OSX 10.13.3
  • Node.js version: v9.3.0

What steps will reproduce the problem?

  1. open browser
  2. take a screenshot
/* eslint-env jest */
/* globals puppeteer */
import Button from './';

describe('<Button />', () => {
  let browser;

  beforeAll(async () => {
    browser = await puppeteer.launch();
  });

  afterAll(async () => {
    await browser.close();
  });

  it('when given a child, it should render w/ image', async () => {
    jest.setTimeout(30000);
    const page = await browser.newPage();
    await page.goto('http://localhost:8000/sandbox');
    const image = await page.screenshot();

    expect(image).toMatchImageSnapshot();
  });
});

What is the expected result?
a screenshot is taken

What happens instead?
a crypitc error

/usr/local/Cellar/node/9.3.0_1/bin/node[91218]: ../src/node_zlib.cc:189:static void node::(anonymous namespace)::ZCtx::Write(const FunctionCallbackInfo<v8::Value> &) [async = false]: Assertion `Buffer::HasInstance(args[4])' failed.
 1: node::Abort() [/usr/local/Cellar/node/9.3.0_1/bin/node]
 2: node::Assert(char const* const (*) [4]) [/usr/local/Cellar/node/9.3.0_1/bin/node]
 3: void node::(anonymous namespace)::ZCtx::Write<false>(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/Cellar/node/9.3.0_1/bin/node]
 4: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/local/Cellar/node/9.3.0_1/bin/node]
 5: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal:

first-time user - any ideas what might be happening? I've tried with system node and nvm, same error. I tried with the latest version of puppeteer and @next

@VinSpee
Copy link
Author

VinSpee commented Feb 16, 2018

it was not the fault of pupeteer, but of jestImageSnapshotMatcher, sorry for the noise!

@VinSpee VinSpee closed this as completed Feb 16, 2018
@aendra-rininsland
Copy link

aendra-rininsland commented Mar 29, 2018

@VinSpee What did you do to resolve it? Anyone arriving here, try downgrading to Node8.

@VinSpee
Copy link
Author

VinSpee commented Mar 29, 2018

@Aendrew here's my working example:

/* eslint-env jest */
import Button from './';

describe('<Button />', () => {
  let browser;

  beforeAll(async () => {
    browser = await puppeteer.launch({
      ignoreHTTPSErrors: true,
    });
  });

  afterAll(async () => {
    await browser.close();
  });

  it('when given a child, it should render', () => {
    const actual = shallow(
      <Button>
        Act now
      </Button>,
    );

    expect(actual).toMatchSnapshot();
  });

  it('when given a child, it should match the image snapshot', async () => {
    const page = await browser.newPage();
    await page.goto('http://localhost:8000/sandbox');
    const button = await page.$('#sample-button');
    const image = await button.screenshot();

    expect(image).toMatchImageSnapshot();
  });

  it('when hovered, it should match the image snapshot', async () => {
    const page = await browser.newPage();
    await page.goto('http://localhost:8000/sandbox');
    const button = await page.$('#sample-button');
    await page.hover('#sample-button');
    const image = await button.screenshot();

    expect(image).toMatchImageSnapshot();
  });
});

@udiedrichsen
Copy link

I opened an issue
americanexpress/jest-image-snapshot#68

@udnisap
Copy link

udnisap commented Apr 15, 2018

The original issue is in the lukeapage/pngjs which uses internal node stream private variables which was changed in the node v9. (nodejs/node@add4b0a#diff-e676e0d24e582043647fd35a459ca91fL253)

pngjs/pngjs#108 fixes pngjs sync method test cases for all node versions upto v9 but the async test cases still fails.

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

Successfully merging a pull request may close this issue.

4 participants