allure2 icon indicating copy to clipboard operation
allure2 copied to clipboard

How to Set Environment details for a Codeceptjs project

Open samaysimantbarik opened this issue 6 years ago • 3 comments

Currently, the environment section in the report for a codecept js project shows blank. What is the way to add the environment details?

image

My config file: image

samaysimantbarik avatar Aug 06 '19 01:08 samaysimantbarik

Can anyone help.

samaysimantbarik avatar Sep 25 '19 22:09 samaysimantbarik

looking at allure environment documentation - the environment widget can be configured with an environment.properties or environment.xml file in the report directory.

heres an example using Codeceptjs event listener API to generate this file into the output directory after all tests have run:

const event = require('codeceptjs').event;
const conf = require('./codecept.conf.js').config;
const fs = require('fs');
  
  event.dispatcher.on(event.all.after, () => {
    let data = 'Environment=STAGE\nBrowser='+conf.helpers.WebDriver.browser
    fs.writeFile(conf.output+'/environment.properties', data, (err) => {
      if (err) throw err;
    });
  });

note: using the Codeceptjs API requires a local codeceptjs installation

Mooksc avatar Oct 25 '19 06:10 Mooksc

will be fixed via https://github.com/allure-framework/allure-js/pull/909

baev avatar May 08 '24 15:05 baev

since [email protected] you can specify environment info and categories via plugin config:

exports.config = {
  plugins: {
    allure: {
      require: require.resolve("allure-codeceptjs"),
      enabled: true,
      environmentInfo: {
        "app version": "123.0.1",
        "some other key": "some other value",
      },
      categories: [...],
    },
  },
};

baev avatar Jul 03 '24 14:07 baev