Describe the bug
Steps are getting skipped, causing the test to fail, when you have an async function as your callback function in table.entries.
To Reproduce
Steps (or project) to reproduce the behavior:
I am using gauge-js with playwright-js. I have the following scenario that has a step with a table:
Create Multiple Orders In Single Test
Login as "user"
Open "site" "811811" from the home page
Create Order
customer
license_type
scope
customer 1
create
other
customer 2
amend
ground space
The step implementation is as follows:
step("Create Order
", async function (table) {
let order = new Order(gauge.dataStore.scenarioStore.get("page"))
await table.entries(async function (entry) {
await order.createOrder(entry["customer"], entry["license_type"], entry["scope"])
})
})
When I run the test I get the following error: UnhandledPromiseRejectionWarning: page.click: Target closed. The page.click is happening in the createOrder async function
I was able to get past this by creating my own instance of the Table function and making async (see below), but am wondering if this can be officially supported or is it already and I just missed it somewhere?
Expected behavior
table.entries waits for the async callback function to complete before proceeding
Additional context
I noticed that the Table entries function is not asynchronous, so I created my own instance and made it asynchronous and now the test runs as expected.
Copied the table function and updated as follows:
var AsyncTable = function (protoTable) {
Object.assign(this, protoTable);
this.entries = async function (callback) {
for (var row of this.rows) {
let entry = {};
row.cells.forEach((cell, index) => entry[this.headers.cells[index]] = cell);
await callback(entry);
}
};
};
module.exports = AsyncTable;
Modified my step implementation as follows:
step("Create Order
", async function (table) {
let order = new Order(gauge.dataStore.scenarioStore.get("page"))
let async_table = new AsyncTable(table)
await async_table.entries(async function (entry) {
await order.createOrder(entry["customer"], entry["license_type"], entry["scope"])
})
@zabil I want to submit a fix for this issue, but the contribution repo is not up to date with the gauge-js master (https://github.com/getgauge-contrib/gauge-jso). How do I get it up to date? Do I have to update it in my fork and submit a separate PR for that first?
Describe the bug Steps are getting skipped, causing the test to fail, when you have an async function as your callback function in table.entries.
To Reproduce Steps (or project) to reproduce the behavior:
I am using gauge-js with playwright-js. I have the following scenario that has a step with a table:
Create Multiple Orders In Single Test
Create Order
The step implementation is as follows:
step("Create Order
})
When I run the test I get the following error: UnhandledPromiseRejectionWarning: page.click: Target closed. The page.click is happening in the createOrder async function
I was able to get past this by creating my own instance of the Table function and making async (see below), but am wondering if this can be officially supported or is it already and I just missed it somewhere?
Expected behavior table.entries waits for the async callback function to complete before proceeding
Versions:
Gauge version: 1.4.3 Commit Hash: f98dd40
Plugins
flash (0.0.2) html-report (4.1.4) js (2.4.0) python (0.3.17) screenshot (0.1.0) spectacle (0.1.4) xml-report (0.2.3)
Additional context I noticed that the Table entries function is not asynchronous, so I created my own instance and made it asynchronous and now the test runs as expected.
var AsyncTable = function (protoTable) { Object.assign(this, protoTable);
};
module.exports = AsyncTable;
step("Create Order
})
@zabil @sriv Does anyone know if this project is still being maintained?
It's not under active development anymore.
Please read https://github.com/getgauge/gauge/issues/1732
PR's to fix issues will be accepted.
@zabil I want to submit a fix for this issue, but the contribution repo is not up to date with the gauge-js master (https://github.com/getgauge-contrib/gauge-jso). How do I get it up to date? Do I have to update it in my fork and submit a separate PR for that first?
https://github.com/getgauge-contrib/gauge-jso is not the correct repo.
You can fork this repo and send a pull request with your changes.
The repo mentioned at https://github.com/getgauge/gauge-js/blob/master/CONTRIBUTING.md
Is wrong, please feel free to correct that too!
@zabil I created a PR that includes the corrected repo in the contributing file. https://github.com/getgauge/gauge-js/pull/571