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

Make golden tests ignore new lines differences #4315

Closed
kblok opened this issue Apr 19, 2019 · 4 comments · Fixed by #4320
Closed

Make golden tests ignore new lines differences #4315

kblok opened this issue Apr 19, 2019 · 4 comments · Fixed by #4320

Comments

@kblok
Copy link
Contributor

kblok commented Apr 19, 2019

I have a few tests throwing errors because Chrome is returning \r\n instead of \n on windows.

How about changing toBeGolden to strip out new lines?

2) Chromium Browser Page Response.text should work (network.spec.js:159:5)
  Message:
    expect.toBe failed: {"foo": "bar"}
 == {"foo": "bar"}

  Stack:
    Error: expect.toBe failed: {"foo": "bar"}
     == {"foo": "bar"}

        at applyMatcher (C:\source\open-source\puppeteer\utils\testrunner\Matchers.js:48:15)
        at it (C:\source\open-source\puppeteer\test\network.spec.js:161:37)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:188:7)

3) Chromium Browser Page Response.text should return uncompressed text (network.spec.js:163:5)
  Message:
    expect.toBe failed: {"foo": "bar"}
 == {"foo": "bar"}

  Stack:
    Error: expect.toBe failed: {"foo": "bar"}
     == {"foo": "bar"}

        at applyMatcher (C:\source\open-source\puppeteer\utils\testrunner\Matchers.js:48:15)
        at it (C:\source\open-source\puppeteer\test\network.spec.js:167:37)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:188:7)

4) Chromium Browser Page JSCoverage should work with conditionals (coverage.spec.js:90:5)
  Message:
    expect.toBeGolden failed: jscoverage-involved.txt mismatch! Output is saved in "output-chromium" directory
  Stack:
    Error: expect.toBeGolden failed: jscoverage-involved.txt mismatch! Output is saved in "output-chromium" directory
        at applyMatcher (C:\source\open-source\puppeteer\utils\testrunner\Matchers.js:48:15)
        at C:\source\open-source\puppeteer        at C:\source\open-source\puppeteer        at C:\source\open-source\puppeteer\test\coverage.spec.js:94:82
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:188:7)

5) Chromium Browser Page CSSCoverage should work with complicated usecases (coverage.spec.js:169:5)
  Message:
    expect.toBeGolden failed: csscoverage-involved.txt mismatch! Output is saved in "output-chromium" directory
  Stack:
    Error: expect.toBeGolden failed: csscoverage-involved.txt mismatch! Output is saved in "output-chromium" directory
        at applyMatcher (C:\source\open-source\puppeteer\utils\testrunner\Matchers.js:48:15)
        at C:\source\open-source\puppeteer        at C:\source\open-source\puppeteer        at C:\source\open-source\puppeteer\test\coverage.spec.js:173:82
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:188:7)
@aslushnikov
Copy link
Contributor

I have a few tests throwing errors because Chrome is returning \r\n instead of \n on windows.

@kblok Interesting. We do run tests on Appveyour - and they run just fine. How can it be?

@kblok
Copy link
Contributor Author

kblok commented Apr 20, 2019

It turns out that I have core.autocrlf in true. What seems to be the default in Windows.
AppVeyor is setting that to input explicitly. see.

Long story short it will turn \n into \r\n get I read text from git and will work the other way around when I push code to GitHub. This is great, but as Chrome returns \n as new lines, tests are failing.

From now on it's up to you 😛

  • We could say, whatever Dario, change that setting.
  • We could document the need of setting that value right in the contributing file.
  • We could improve toBeGolden to support these differences.

@aslushnikov
Copy link
Contributor

We could improve toBeGolden to support these differences.

This would loosen the assertions, making it more "magical" - I don't like it

We could document the need of setting that value right in the contributing file.

This sounds good! It'll also embrace a similar setup for all our contributors.

Would you mind sending a PR? You might have a good idea on what to say in CONTRIBUTING.MD since you're going through this right now.

@kblok
Copy link
Contributor Author

kblok commented Apr 20, 2019

Will do!

aslushnikov pushed a commit that referenced this issue Apr 22, 2019
Although we said on #4315 to add just a comment in the CONTRIBUTING.md file. I think this solution will be better for the repository's health.

We could also apply this for `*.js` but it's up to you.

This is what I needed to run after I added this file:
```
git rm --cached -r .
git reset --hard
```

Fixes #4315
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.

2 participants