Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taiko confirm(func) doesn't work with gauge-js #384

Closed
navel3 opened this issue Sep 1, 2020 · 4 comments
Closed

Taiko confirm(func) doesn't work with gauge-js #384

navel3 opened this issue Sep 1, 2020 · 4 comments
Assignees
Labels

Comments

@navel3
Copy link

navel3 commented Sep 1, 2020

Expected behavior

The callback function passed to confirm(func) is called.

Actual behavior

Actual confirm dialog is shown, and following message is printed in the console.

There is no handler registered for confirm popup displayed on the page file:///home/vagrant/dev/gauge-test/index.html.
This might interfere with your test flow. You can use Taiko's confirm API to
handle this popup.
Please visit https://docs.taiko.dev/#confirm for more details

Steps to reproduce

  1. gauge init js

  2. Create following files in the project directory.

[index.html]
<!DOCTYPE html>
<html lang="en">
<body>
  <button onclick='window.confirm("test")'>Press</button>
</body>
</html>
[specs/confirm.spec]
# Confirm test

## Step
* Perform
[tests/confirm.js]
const { goto, click, button, confirm, accept } = require("taiko");
const { print } = require("./mod.js");

step("Perform", async () => {
  const f = () => {};
  console.log("1", typeof f, f instanceof Function); // 1 function true
  print(f); // 2 function false

  await goto("file:///<project-dir>/index.html");
  confirm(async () => {
    console.log("ok");
    await accept();
  });
  await click(button("Press")); // actual confirm dialog is shown
});
[tests/mod.js]
const print = (f) => console.log("2", typeof f, f instanceof Function);
module.exports = { print };
  1. gauge run specs/confirm.spec

Note

  • As commented in the above, it seems to a function passed to function which is defined in other module is not evaluated as instanceof Function.
  • When run a javascript file with node command, a function passed to imported function is evaluated as instanceof Function normally.
  • In Taiko REPL, confirm(func) is works normally.
  • confirm("string or regex", func) is works normally even with gauge-js.

Versions

Gauge version: 1.1.1
Plugins
-------
html-report (4.0.12)
js (2.3.12)
screenshot (0.0.1)
@navel3
Copy link
Author

navel3 commented Sep 3, 2020

This behavior may relates.

nodejs/node-v0.x-archive#1277

@NivedhaSenthil
Copy link
Member

Thanks for reporting, could replicate the issue we will look at fixing this.

@NivedhaSenthil NivedhaSenthil self-assigned this Sep 8, 2020
NivedhaSenthil added a commit to getgauge/taiko that referenced this issue Sep 8, 2020
NivedhaSenthil added a commit to getgauge/taiko that referenced this issue Sep 10, 2020
* use helper method to check for type

getgauge/gauge-js#384

Signed-off-by: NivedhaSenthil <[email protected]>

* Bump version to 1.0.22

Signed-off-by: NivedhaSenthil <[email protected]>

* update regex check

Signed-off-by: NivedhaSenthil <[email protected]>

* fix date type check

Signed-off-by: NivedhaSenthil <[email protected]>

Co-authored-by: Srikanth <[email protected]>
@NivedhaSenthil
Copy link
Member

Fixed in latest version of Taiko 1.0.23

@navel3
Copy link
Author

navel3 commented Sep 16, 2020

I have checked the latest version.
The issue is gone. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants