Skip to content

[🐛 Bug]: Allure reporter adding environment value overwrites the last value #10321

@m4hdyar

Description

@m4hdyar

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

v16.13.2

Mode

WDIO Testrunner

Which capabilities are you using?

No response

What happened?

When using allureReporter.addEnvironment() the new value overwrites the last value.

The problem comes from

this._allure.writeEnvironmentInfo({
.

I guess the reason is that in allure reporter you should now set all environment variables at once as it is a Record<string,string>, which makes IMHO also sense.

What is your expected behavior?

I have two approaches to solve the problem, and I'm happy to implement whichever one the community prefers.

  1. Setting all variables in wdio.conf in the reporter configuration is the first approach. Normally, you would not/should not change environment variables during the tests. So IMHO something like this makes sense:
reporters: [['allure', {
    outputDir: 'allure-results',
    environment: [
        a:'a',
        b:'b'
    ]
}]],
  1. Changing addEnvironment(name: string, value: string) to setEnvironment(Record<string,string>) is the second approach.

The second one is more flexible, but in my opinion, the first one is the right approach because the second one opens the door to mistakes and makes it possible to overwrite the environment variable information.

How to reproduce the bug.

Just write this anywhere in your test:

allureReporter.addEnvironment('d', 'c');
allureReporter.addEnvironment('a', 'b');

Relevant log output

a b

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions