codeceptjs / codeceptjs/CodeceptJS

Run-workers doesn't start Data() tests with generated values(faker) in DataTable

Open
#2,550 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.2k
Forks
757
Avg merge
2d 9h
Merged PRs (30d)
16

Description

#### What are you trying to achieve?
I have some Data tests where I add new objects in DataTable.
In Object1 and Object3 I have only constant fields.
In Object2 I have faker to generate new value for every new object.

When I start this test with run-workers there are only cases with Object1 and Object3 will start.

It is happens because we compile tests in main thread and generate testId(I think from test data) than divides tests among workers.
Than we compile tests again in workers and receive new value inside object so we have new testId.
For example, for 3 workers we will have testId in main thread and 3 different testId for workers and all 4 testId for one testcase in Datatest. So workers will not find testId for this case in publicWorker.workerData.tests array and will not start it.

I have already changed my tests, but I found this problem when I was moving for run-multiple and checked tests quantity in reporter.
Some people can lose tests because of this problem and don't realize it.

```js
const table = new DataTable(['param1', 'param2']);
table.add(['df', new Object1()]);
table.add(['ddf', new Object2()]);
table.add(['nv', new Object3()]);

class Object1 {
constructor() {
this.someField = 'asdfa';
}
}

class Object2 {
constructor() {
this.someField = faker.random.alphaNumeric(5);;
}
}

class Object3 {
constructor() {
this.someField = 'asdfsdfa';
}
}
```

### Details

* CodeceptJS version: 2.6.5
* NodeJS Version: 12
* Operating System: win/linux
* puppeteer || webdriverio || protractor || testcafe version (if related)
* Configuration file:

```js
tests: './tests/**/*_test.js',
output: './output',
helpers: {
WebDriver: {
url: 'http://localhost',
browser: 'chrome',
smartWait: 10000,
waitForTimeout: 10000,
restart: true,
windowSize: 'maximize',
desiredCapabilities: {
chromeOptions: {
prefs: {
'plugins.always_open_pdf_externally': true,
'profile.default_content_settings.popups': 0,
'profile.default_content_setting_values.automatic_downloads': 1,
'download.prompt_for_download': false,
'download.default_directory': path.join(process.cwd(), 'output', 'downloads'),
},
},
},
},
ChaiWrapper: {
require: 'codeceptjs-chai',
},
FileSystem: {},
},
include,
bootstrap: null,
name: 'simple',
plugins: {
wdio: {
enabled: true,
services: ['selenium-standalone'],
},
screenshotOnFail: {
enabled: true,
fullPageScreenshots: true,
},
allure: {},
},
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.