Replies: 8 comments
-
You can retrieve your chunks configuration with the following
As well as access them globally:
Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
@xMutaGenx thanks. What I'm trying to do is get the current chunk number. With const chunks = require('codeceptjs').config.get()['multiple']['parallel']['chunks'];
Before(() =>
allure.addLabel('thread', process.env.CHUNKS)
) Every test is recorded as thread 4 (the number of chunks). |
Beta Was this translation helpful? Give feedback.
-
Ah apologies @theptyza misunderstood you then, one way you could do this is by accessing the mocha child processes: let child = require('codeceptjs').config.get().mocha.child; This will give you something like child = child.substring(0, child.indexOf('.')); Finally you'll have something like: Before(() => {
let child = require('codeceptjs').config.get().mocha.child;
child = child.substring(0, child.indexOf('.'));
allure.addLabel('thread', child)
}) Not the cleanest approach, but it works, might allow you to continue working until a better solution appears 🤷♂ Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
I was able to use process ID as thread number for Allure report by creating a helper that sets thread label for each test let Helper = codecept_helper;
const process = require('process');
class AllureHelper extends Helper {
_before() {
const allure = codeceptjs.container.plugins('allure');
allure.addLabel('thread', process.pid);
}
}
module.exports = AllureHelper; Wondering if there is a better way to do this. |
Beta Was this translation helpful? Give feedback.
-
@xMutaGenx thanks! Your solution is even better since it gives the actual chunk number. |
Beta Was this translation helpful? Give feedback.
-
@theptyza or @xMutaGenx could you share the configuration to achive this |
Beta Was this translation helpful? Give feedback.
-
@Naimadnap I've created an allureHelper 'use strict';
let Helper = codecept_helper;
class AllureHelper extends Helper {
_before() {
let child = codeceptjs.config.get().mocha.child;
// if there are child processes set thread label in Allure report to chunk number
// child process name is like '1.parallel:chunk1:default'
if(child) {
const allure = codeceptjs.container.plugins('allure');
allure.addLabel('thread', child.substring(0, child.indexOf('.')));
}
}
}
module.exports = AllureHelper; and included it in codecept.conf.js helpers: {
Nightmare: {
url: process.env.CODECEPT_URL || "http://localhost:3000",
windowSize: "1920x1080",
typeInterval: "-1"
},
allureHelper: {
require: "./test/helpers/allureHelper.js",
}
}, |
Beta Was this translation helpful? Give feedback.
-
What about const { threadId } = require('worker_threads');
const allure = codeceptjs.container.plugins('allure');
allure.addLabel('thread', threadId); ? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What are you trying to achieve?
I'm running tests in parallel with 4 chunks and write reports to Allure.

I want to see tests from each chunk displayed in a separate timeline. If I manually add a "thread" label to each suite or test (in the XML) I can split the test results into multiple timelines.
What do you get instead?
By default in the Allure report all tests are displayed in one timeline.

I can add labels to test cases like
My question is - how can I get the chunk number in the test?
Details
Running tests with
Beta Was this translation helpful? Give feedback.
All reactions