cucumber / gherkin-utils

API for working with Gherkin documents
MIT License
9 stars 4 forks source link

Fix the javascript/windows build #2

Closed mattwynne closed 6 months ago

mattwynne commented 1 year ago

🤔 What's the problem you've observed?

Javascript tests fail on Windows

e.g. https://github.com/cucumber/gherkin-utils/actions/runs/3504533429/jobs/5870269520

✨ Do you have a proposal for making it better?

Figure it out and fix it.

📚 Any additional context?

Breaking this out of scope of #1


This text was originally generated from a template, then edited by hand. You can modify the template here.

jennek commented 1 year ago

The problem seems to be in javascript/test/messageTest.ts line 15

  const tckMessageFiles = fg.sync(
    `${__dirname}/../node_modules/@cucumber/compatibility-kit/features/**/*.ndjson`
  )

The files are definitely there, yet fg.sync returns an empty array. So something must be wrong with the glob pattern.

fastglob requires POSIX style patterns, in particular forward slashes. __dirname contains a Windows style path with backward slashes. Replacing __dirname with __dirname.replace(/\\/g, '/') solved it for me. Using unixify would be the more elegant solution.

Source https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows

jennek commented 1 year ago

there is a similar issue here https://github.com/cucumber/gherkin-utils/blob/main/javascript/test/prettyTest.ts#:~:text=const%20featureFiles%20%3D%20fg.sync(%60%24%7B__dirname%7D/../../../gherkin/testdata/good/*.feature%60)

as no files are found by fg.sync, no tests are run. This does not break the build so it is easy to overlook.