Skip to content

Commit

Permalink
test(cucumber): join all paths with path module (#2694)
Browse files Browse the repository at this point in the history
Co-authored-by: Amir Blum <amirgiraffe@gmail.com>
  • Loading branch information
Ugzuzg and blumamir authored Feb 9, 2025
1 parent ce62d8c commit c28ae72
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions plugins/node/instrumentation-cucumber/test/cucumber.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,23 @@ describe('CucumberInstrumentation', () => {
providedConfiguration?: Partial<IConfiguration>
) => {
// clean-up require cache to re-register cucumber hooks for a new run
['features/support/world', 'features/step_definitions/steps'].forEach(
search => {
const key = Object.keys(require.cache).find(key =>
key.includes(search)
);
if (key == null) return;
delete require.cache[key];
}
);
[
path.join('features', 'support', 'world'),
path.join('features', 'step_definitions', 'steps'),
].forEach(search => {
const key = Object.keys(require.cache).find(key => key.includes(search));
if (key == null) return;
delete require.cache[key];
});
const featurePath = path.join(__dirname, 'current.feature');
await fs.promises.writeFile(featurePath, feature, 'utf-8');
const { runConfiguration } = await loadConfiguration({
provided: {
...providedConfiguration,
paths: [featurePath],
require: [
path.join(__dirname, 'features/support/world.ts'),
path.join(__dirname, 'features/step_definitions/steps.ts'),
path.join(__dirname, 'features', 'support', 'world.ts'),
path.join(__dirname, 'features', 'step_definitions', 'steps.ts'),
],
},
});
Expand Down Expand Up @@ -170,7 +169,7 @@ describe('CucumberInstrumentation', () => {
assert(parent, 'Expected a parent span');

assert.deepEqual(parent.attributes, {
[SEMATTRS_CODE_FILEPATH]: 'test/current.feature',
[SEMATTRS_CODE_FILEPATH]: path.join('test', 'current.feature'),
[SEMATTRS_CODE_LINENO]: 7,
[SEMATTRS_CODE_FUNCTION]: 'Button pushing',
[SEMATTRS_CODE_NAMESPACE]: 'Basic',
Expand Down

0 comments on commit c28ae72

Please sign in to comment.