amiceli/vitest-cucumber

Suggestion: change the base path of loadFeature from cwd to the caller file's paths

Closed this issue · 4 comments

outline

as-is

// ./src/path/to/feature/foo.test.tsx

import { loadFeature } from '@amiceli/vitest-cucumber'

const feature = await loadFeature('./src/path/to/feature/foo.feature')
// ...

to-do

// ./src/path/to/feature/foo.test.tsx

import { loadFeature } from '@amiceli/vitest-cucumber'

const feature = await loadFeature('./foo.feature')
// ...

explanation

Hello there!
I think the base path of loadFeature on as-is could cause a little trouble when we move a spec (or test) file to another path.
(whenever that happens, it seems that we need to change each path that is passed to loadFeature as a parameter.)

so, I suggest changing the base path of it to the caller file's paths.
or what do you think about making a loader for the feature file and connecting its result with your package?

I appreciate your efforts for this package.

related link

.fromPath(path)
.parseFile()

Hi @ytw0728 ,

Your issue is a good point ;).
I make some search about it and I found posts and/or framework docs using both solutions : same folder or different folders.

So I will work on it to allow both ways.
I will show you it on this issue and you will give me your opinion ;)

@ytw0728 ,
I found a solution to load feature file in both ways.
If you want, you can check code in #50 .

I'm working on it to improve my unit tests for it.

It's done, I have published a new version https://github.com/amiceli/vitest-cucumber/releases/tag/v3.2.3
You can install new version to use relative path ;).

@amiceli
Thanks for your super fast solving!!!
It looks much better than what I requested.

Have a wonderful one!