@amiceli/vitest-cucumber
Version:
vitest tools to use Gherkin feature in unit tests
20 lines (19 loc) • 721 B
JavaScript
import { dirname } from 'node:path';
import callsites from 'callsites';
import { FeatureFileReader } from '../parser/readfile';
import { getVitestCucumberConfiguration } from './configuration';
function getCallerPath() {
const { 2: callerFilePath } = callsites();
const callerFileName = callerFilePath?.getFileName() || ``;
const callerFileDir = dirname(callerFileName);
return callerFileDir;
}
export async function loadFeature(featureFilePath, options) {
const callerFileDir = getCallerPath();
const [feature] = await FeatureFileReader.fromPath({
featureFilePath,
callerFileDir,
options: getVitestCucumberConfiguration(options),
}).parseFile();
return feature;
}