getgauge / taiko

A node.js library for testing modern web applications

Home Page:https://taiko.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can not use assert.fail() in a alert()

ArthurGLACET opened this issue · comments

Describe the bug
When using assert.fail(); inside the callback of a alert() the browser closes

To Reproduce
Steps (or script) to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error
const {
    openBrowser,
    closeBrowser,
    goto,
    alert,
    click,
    accept
} = require('taiko');
const assert = require('assert');

    await openBrowser();

    await goto("https://testpages.herokuapp.com/styled/alerts/alert-test.html");

    alert("I am an alert box!", async() => {
        await accept();
        assert.fail();
    });

    await click("Show alert box");

    await closeBrowser();
AssertionError [ERR_ASSERTION]: Failed
at c:\gauge-test-popUp\tests\step_implementation.js:28:16
at async EventEmitter.<anonymous> (c:\gauge-test-popUp\node_modules\taiko\lib\taiko.js:2541:5) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: undefined,
expected: undefined,
operator: 'fail'
}
Waiting for the debugger to disconnect...
        
        Failed Step: test step
        Specification: c:\gauge-test-popUp\specs\example.spec:5
        Error Message: error reading from server: read tcp 127.0.0.1:58501->127.0.0.1:58500: wsarecv: An existing connection was forcibly closed by the remote host.
        Stacktrace: 
        
        Error Message: Runner is not Alive
        Stacktrace: 
        
    Error Message: Runner is not Alive
    Stacktrace: 
    
  Error Message: Runner is not Alive
  Stacktrace: 
  

  Error Message: Runner is not Alive
  Stacktrace: 

Expected behavior
the test should fail but the browser should not close

Versions:

  • Taiko: Version: 1.3.5 (Chromium: 104.0.5109.0) RELEASE
  • OS: Windows 10 Professionnel 22H2
  • Node.js v18.12.0
gauge -v
Gauge version: 1.4.3
Commit Hash: f98dd40

Plugins
-------
html-report (4.2.0)
js (2.4.0)
screenshot (0.1.0)

Additional context
Add any other context about the problem here.