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

The line feed on windows is failing the tests #22

Closed
ncochard opened this issue Jan 22, 2018 · 2 comments
Closed

The line feed on windows is failing the tests #22

ncochard opened this issue Jan 22, 2018 · 2 comments

Comments

@ncochard
Copy link

Hello

I'm using babel-plugin-tester to test a Babel plugin I am working on. (Great tool BTW; thanks for sharing this.)

My tests were failing for no apparent reason. Then I realize that the following line of code was returning an error because of a difference with the line feed \r\n vs \n.

I fixed the problem by replacing the following line of code:

assert.equal(actual, output, 'actual output does not match output.js')

... with this ...

const normalizeNewline = require('normalize-newline');
assert.equal(normalizeNewline(actual), normalizeNewline(output), 'actual output does not match output.js')
@kentcdodds
Copy link
Member

Hi @ncochard!

That makes sense. Normally in my projects I'll include a .gitattributes that includes this:

*.js text eol=lf

This helps me avoid these kinds of problems. That said, I can understand why this tool should be built to work regardless. So feel free to open a pull request to address this. Thanks!

@eps1lon
Copy link
Contributor

eps1lon commented Mar 10, 2019

Normally in my projects I'll include a .gitattributes that includes this:

I think this should be the accepted solution. The linefeed is currently hardcoded into babel so any test that expectes \r\n as a linefeed should actually fail. The babel repo itself uses text eol=lf so I don't think this is the right place for a fix. If anything then @babel/generator should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants