nvim-neotest / neotest-jest

MIT License
116 stars 79 forks source link

fix(windows): path reducing for jest pattern #116

Open eugeny-dementev opened 5 months ago

eugeny-dementev commented 5 months ago

Fix for https://github.com/nvim-neotest/neotest-jest/issues/113

There are few issues with it on windows:

Solution in the PR is to reduce windows version of path to the same pattern it is for unix: C:/project\__tests__/file.test.ts => __tests__/file.test.ts.

Fix is universal, on unix vim.fn.substitute (string replace) just doesn't do anything since path already lacking cwd part

I've tested it on both windows and ubuntu and it seem to work as intended on both platforms

Help needed with writing tests because ./scripts/test throws an error for me so I have no idea if I broke something

Error detected while processing command line:
E492: Not an editor command: PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.vim'}
conermurphy commented 5 months ago

I had the same issues with running the tests locally, raised an issue for it here #114 to try get some help from others.

JanPeter commented 4 months ago

I'm using Neovim in Windows 11 with PowerShell 7.4.1 and it only works for me after I apply your code and remove the escapeTestPattern call.

BitsAndDroids commented 3 months ago

I'm using Neovim in Windows 11 with PowerShell 7.4.1 and it only works for me after I apply your code and remove the escapeTestPattern call.

I've encountered the same issue. To fix this I've had to gsub out the backslash characters for it to work. It seems to normalize the path to C:\/....\/.... which windows does not like.

escapeTestPattern(reducePattern(cwd, pos.path)):gsub("\\", ""),